|
-
September 13th, 2001, 11:04 AM
#1
sum function
here is my code
Sub SubComputeArea_Click()
Dim sum, sum1, sum2
sum1 = Text1: sum2 = Text2
sum = (sum1 + sum2) ' add area of rectangle.
Text3 = sum ' Print Area to Debug window.
End Sub
if change the + to *,/,- it works fine but as a + it returns the 2 numbers joined like this 5+5=55 or 2+2=22 not 5+5=10 what is worng here....
thanx in advance
midnightservice
-
September 13th, 2001, 11:08 AM
#2
Re: sum function
Hi,
This is because '+' is a operater to connect two string, and by default, textbox contains string. Try this:
=====
Sub SubComputeArea_Click()
Dim sum as long
dim sum1 as long
dim sum2 as long
sum1 = clng(Text1)
sum2 = clng(Text2)
sum = (sum1 + sum2) ' add area of rectangle.
Text3 = sum ' Print Area to Debug window.
End Sub
=====
Regards,
Michi
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
|