|
-
May 29th, 2001, 03:36 PM
#1
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]
-
May 29th, 2001, 03:45 PM
#2
Re: adding 2 variables
Dimension add as any numeric datatype
e.g. dim add as integer
-
May 29th, 2001, 03:46 PM
#3
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.
-
May 30th, 2001, 01:51 PM
#4
Re: adding 2 variables
Thanks!
That solved my problem
--Ant
------------------------------------------------------------------------------------------------------------------------
Want Free Software?
E-mail me @: [email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|