Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A stupid question

Status
Not open for further replies.

Cndn

Programmer
Nov 22, 2001
22
0
0
CA

Text3.text = text2.text + text1.text

If text2 is equal to 2, and text1 is equal to 1, then
text3 will equal 21.

Isn't it possible to have the code simply add text2's text (2) and text1's text (1) to equal 3?

How do you make it so that vb adds the values instead of sticking them together?
 
cast them to ints or longs

text3.text = clng(text2.text) + clng(text1.text)

this will cause an error if either of the values are not numbers so check first before casting

if isnumeric(text2.text) and isnumeric(text1.text) then
text3.text = clng(text2.text) + clng(text1.text)
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top