|
-
October 4th, 1999, 12:44 AM
#1
Add 2 numbers
I want to add whatever is in Text1.text and Text2.text
well I tried to use text3.text = text1.text + text2.text but it shows me like if Text1 had 5 and text2 had 7 then it shows me 57 instead of 12
How can I asign a + so that my program will think that + stands for "add", multiply (*) works perfect...
-
October 4th, 1999, 01:56 AM
#2
Re: Add 2 numbers
text3.text = cint(text1.text) + cint(text2.text)
-
October 5th, 1999, 07:08 AM
#3
Re: Add 2 numbers
Alternatively try this :
result = val(trim(text1.text)) + val(trim(text2.text))
---Siva----
-
October 5th, 1999, 07:30 AM
#4
Re: Add 2 numbers
U'r question is very basic, In visual basic '+' operator can be used for two purpose based on the values, if u give strings in both the sides, the operator will taken as a string concatenator. if u want to add two numbers u have to convert the string into number using the functions Cint or Val. Because the textbox will treat all values as a string only.
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
|