Adding Problems

D

DS

I have 2 unbound Textboxes set to general number format.
If I do...
Textbox1 = 4 Textbox2 = 2

Textbox1 * Textbox2 = 8 Correct!
Textbox1 / Textbox2 = 2 Correct!
Textbox1 - Textbox2 = 2 Correct!
Textbox1 + Textbox2 = 42 Wrong !!!

it should be 6 why is this happening?

Any insight appreciated.
Thanks
DS
 
R

Rick Brandt

DS said:
I have 2 unbound Textboxes set to general number format.
If I do...
Textbox1 = 4 Textbox2 = 2

Textbox1 * Textbox2 = 8 Correct!
Textbox1 / Textbox2 = 2 Correct!
Textbox1 - Textbox2 = 2 Correct!
Textbox1 + Textbox2 = 42 Wrong !!!

it should be 6 why is this happening?

Any insight appreciated.
Thanks
DS

The values are being interpretted as strings rther than numbers. Try...

CDbl(Textbox1) + CDbl(Textbox2)

If the TextBoxes will never have any decimal values then you could use...

CLng(Textbox1) + CLng(Textbox2)
 
D

DS

Rick said:
The values are being interpretted as strings rther than numbers. Try...

CDbl(Textbox1) + CDbl(Textbox2)

If the TextBoxes will never have any decimal values then you could use...

CLng(Textbox1) + CLng(Textbox2)
Rick, worked great! Thank you once again!
DS
 
Top