PDA

View Full Version : My wrong calculator code.


Mina Zaki
Mar 28, 2008, 03:06 PM
i did a very simple calculator

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



And this is my code

http://aycu30.webshots.com/image/47789/2003224651406407843_rs.jpg



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

http://aycu14.webshots.com/image/47413/2003226318421073932_rs.jpg


http://aycu31.webshots.com/image/51030/2003242519318393365_rs.jpg



what is the wrong?????

please i need your help!!!!!!:mad:

Username Here
Mar 29, 2008, 10:18 AM
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

kabia
Apr 3, 2008, 11:46 PM
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