calculations

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • freefony
    New Member
    • Nov 2008
    • 59

    calculations

    pls wats wrong with ma codes
    <code>
    Dim score as integer
    Dim percentagescore as integer
    Dim calculated score as integer
    Dim percent as integer
    Dim mark as integer
    score = intscore.text
    mark= intmark.text
    percent= percent.text
    percentagescore = (score * 100)/mark
    calculatedscore = (percentagescor e * percent)/100
    connection string
    dim command as sqlcommand= ("INSERT INTO score([score],[mark],[percent],[calculatedscore]) VALUES (@score,@mark,@ percent,@calcul atedscore)
    connect.open()
    command.execute nonquery()
    connect.close
    </codes>
    pls i need help quick its tell conversion from type string to integer is illegal i dont see where i converted
  • BrianP
    New Member
    • Jan 2009
    • 4

    #2
    Try this for setting your variables

    score = CINT(intscore.t ext)
    mark= CINT(intmark.te xt)
    percent= CINT(percent.te xt)


    Also, you may want to consider using Decimal or another variable type for your decleration. Integers are only hole numbers 1, 2 3, ect. so if you percentage ends up as a decimal it might cause issues

    Comment

    Working...