Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Visual Basic (https://www.askmehelpdesk.com/forumdisplay.php?f=469)
-   -   My wrong calculator code. (https://www.askmehelpdesk.com/showthread.php?t=199725)

  • Mar 28, 2008, 03:06 PM
    Mina Zaki
    My wrong calculator code.
    i did a very simple calculator

    http://img176.imageshack.us/img176/7314/52886418qe8.png


    And this is my code

    http://aycu30.webshots.com/image/477...6407843_rs.jpg


    And this is the problem when i tried it.......


    http://aycu14.webshots.com/image/474...1073932_rs.jpg


    http://aycu31.webshots.com/image/510...8393365_rs.jpg

    [CENTER]
    what is the wrong?????

    please i need your help!!!!!![/
    CENTER]:mad:
  • Mar 29, 2008, 10:18 AM
    Username Here
    Try "Else If"

    I haven't done VB in a while, but I can't remember weather it will allow more than one if statement per private sub. If not try making A and B integers. Correct syntax means that "Text3.Text = A + B" should have its own line, but it's a single line If statement so it may not affect it.

    sorry I couldn't be of much help, I haven't done VB in a while. I'm a C# nerd atm.
    Louis
  • Apr 3, 2008, 11:46 PM
    kabia
    If you put :

    "If Option1.value = true then Text3.text = A + B"

    On one line...
    You do not need to put the "end if" statement

    But to correct your issue...

    Private Sub Command1_Click()
    Dim A, B
    A = Val(Text1.text)
    B = Val(text2.text)
    If Option1.value = true then
    Text3.text = A + B
    end if
    If Option2.value = true then
    Text3.text = A - B
    end if
    If Option3.value = true then
    Text3.text = A * B
    end if
    If Option4.value = true then
    Text3.text = A / B
    end if

  • All times are GMT -7. The time now is 02:11 AM.