ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   incorrect addition (https://www.excelbanter.com/excel-programming/363792-incorrect-addition.html)

[email protected]

incorrect addition
 
I have three textboxes:
Contents Premium name:contents
Bldg Premium name:bldg
Total Premium name:total

Total.Value = Contents.Value + Bldg.Value
When I add the above line to calculate the total premium, it does not
add, it concatenates. eg. if I put 10000 in Contents Premium and 50 in
Bldg Premium, ideally it should show 10050 but it is showing 1000050

Total.Value = Contents.Value - Bldg.Value
The above line for subtracting works fine.

Any ideas???


Mike Fogleman

incorrect addition
 
Total.Value = Sum(Contents.Value, Bldg.Value)

wrote in message
ps.com...
I have three textboxes:
Contents Premium name:contents
Bldg Premium name:bldg
Total Premium name:total

Total.Value = Contents.Value + Bldg.Value
When I add the above line to calculate the total premium, it does not
add, it concatenates. eg. if I put 10000 in Contents Premium and 50 in
Bldg Premium, ideally it should show 10050 but it is showing 1000050

Total.Value = Contents.Value - Bldg.Value
The above line for subtracting works fine.

Any ideas???




[email protected]

incorrect addition
 
Your TEXT boxes contain text, so VBA will add the two text strings
together as you have requested - two options for you

(1) store the results of the textboxes on the worksheet and have a
formula to sum them
(2) amend your code to be
total.value=val(contents.value)+val(Bldg.Value)

wrote:
I have three textboxes:
Contents Premium name:contents
Bldg Premium name:bldg
Total Premium name:total

Total.Value = Contents.Value + Bldg.Value
When I add the above line to calculate the total premium, it does not
add, it concatenates. eg. if I put 10000 in Contents Premium and 50 in
Bldg Premium, ideally it should show 10050 but it is showing 1000050

Total.Value = Contents.Value - Bldg.Value
The above line for subtracting works fine.

Any ideas???



[email protected]

incorrect addition
 
Thanks



wrote:
Your TEXT boxes contain text, so VBA will add the two text strings
together as you have requested - two options for you

(1) store the results of the textboxes on the worksheet and have a
formula to sum them
(2) amend your code to be
total.value=val(contents.value)+val(Bldg.Value)




All times are GMT +1. The time now is 04:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com