Consulting

Results 1 to 3 of 3

Thread: Adding Values in a Userform

  1. #1

    Adding Values in a Userform

    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.
    Capture.JPG


    Any help is greatly appreciated.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    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")

  3. #3
    Thanks a millions! That worked out perfectly and it's good info to keep in mind for the future.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •