Click to See Complete Forum and Search --> : adding 2 variables


ant
May 29th, 2001, 03:36 PM
I want the user to enter 2 numbers in 2 different text boxes and store them in 2 variables:

Dim num1 as single
Dim num2 as Single
num1 =Text1.text
num2 = Text2.text



Now when the user clicks on a command button, i want it to add the to text boxes and put the answer in another text box:

private Sub Figureout_Click()
Dim add as string
add = num1 + num2
Text3.text = add
End Sub



but when i do that myself, say i put 1 in the first text box and 2 in the 2nd text box. It comes out: 12.

Does any1 know how to make it come out 3 instead of 12???

--Ant
------------------------------------------------------------------------------------------------------------------------
Want Free Software?
E-mail me @: cgeorge@thevortex.com

phunkydude
May 29th, 2001, 03:45 PM
Dimension add as any numeric datatype

e.g. dim add as integer

ohad21
May 29th, 2001, 03:46 PM
Hi You Should Define the Add as a single also and use the Val and Str Functions.
Try this code in your function:


Dim add as Single
num1 = Val(Text1.Text)
num2 = Val(Text2.Text)
add = num1 + num2
Text3.Text = Str(add)




I hope this solves your problem.

ant
May 30th, 2001, 01:51 PM
Thanks!

That solved my problem




--Ant
------------------------------------------------------------------------------------------------------------------------
Want Free Software?
E-mail me @: cgeorge@thevortex.com