PDA

View Full Version : [SOLVED] Adding Values in a Userform



llldebaserll
09-17-2013, 01:04 PM
I am trying to add the values of two TextBoxs on a Userform. I've multiplied and divided various added values to get a set of numbers but when I try to add those new values together to obtain a total, it just lists the two numbers instead of adding them.


MultipleDNEntryForm.InvoiceAmountBox1 = Format(DNTotCharge1 + FuelChargeBox1, "#,##0.00")

"Invoice Amount" is supposed to equal the sum of "DN Total Charge" + "Fuel Charge" but as you can see below, it's just listing the boxes.
10591


Any help is greatly appreciated.

Kenneth Hobs
09-17-2013, 01:27 PM
Welcome to the forum!

The variable type for a TextBox is text, not numbers. A "$" in not a number. A " " is not a number. A "," is not a number. You will need to Replace() those sorts of characters. Since you are using decimals, after replacing characters, convert the strings to double. e.g.

MultipleDNEntryForm.InvoiceAmountBox1 = Format(cdbl(DNTotCharge1) + cdbl(FuelChargeBox1), "#,##0.00")

llldebaserll
09-17-2013, 02:04 PM
Thanks a millions! That worked out perfectly and it's good info to keep in mind for the future.