Chris25
October 15th, 2001, 11:06 AM
Hi everyone! I need a little help with a calculator i am developing. Heres the layout...... 3 text boxes(each one labeled firstnumber,secondnumber, and product). Also i have 4 option buttons(add,subract,multiply, and divide) and i have one command button that calculates the totals from the first two text boxes. Now how do i write the code for the option buttons so that when i click each one of them they will add , sub, multiply and divide. When i try to write the code different ways i keep getting compile error. Also do i put most of the code in the command button, so when i click it the input in the first two text boxes either adds them, subtracts them, multiplys or divides?? Thanks for any help you can give me.
John G Duffy
October 15th, 2001, 12:03 PM
put the code in the command button click event. there you look to see what option button is checked and perform associated operation.
John G
Cakkie
October 15th, 2001, 12:29 PM
Something like this maybe?
private Sub Command1_Click()
Select Case true
Case optAdd
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
Case optSub
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
Case optMul
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
Case optDiv
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End Select
End Sub
Note to merrion: I used your if-then-elseif-to-select-case method you posted on http://www.vbcodelibrary.co.uk/board, and I like it!
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook