-
adding 2 variables
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 @: [email protected]
-
Re: adding 2 variables
Dimension add as any numeric datatype
e.g. dim add as integer
-
Re: adding 2 variables
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.
-
Re: adding 2 variables
Thanks!
That solved my problem
--Ant
------------------------------------------------------------------------------------------------------------------------
Want Free Software?
E-mail me @: [email protected]