Results 1 to 7 of 7

Thread: Adding Decimals

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482

    Question

    Hey, i use the code

    Equals = Str(Val(text1.text) + val(text2.text))

    and it works perfectly..
    altho i need it to Add decimals..
    (if u try this out with a decimal, it ROUNDS the decimal..)

    like money, so
    $2
    $2.10
    $3.00

    would = 7.10

    How would i do this? thanks

  2. #2
    Lively Member
    Join Date
    Jul 2000
    Location
    Ireland, Dublin
    Posts
    76

    Talking

    Use the Format command.

    result = FORMAT("7", "#0.00")

    This should convert '7' to '7.00'

    Hope this is of some help
    ---------------------------------
    TopMan
    ---------------------------------

  3. #3
    Guest
    You can omit the pound sign.

    Code:
    Equals = Str(Text1) + Val(Text2)
    Equals = Format(Equals, "0.00")
    Print Equals

  4. #4
    Junior Member
    Join Date
    Jul 2000
    Posts
    17
    Did you Dim Equals as Integer?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482

    Question

    THANKS.. but its not there yet..

    i type in
    2
    2.00
    and
    2.56

    in the 3 boxes that i have..

    When i ADD THEM ALL UP
    it just appears as

    7.00

    it is still ROUNDING the .56

    how would i do this so it adds all the CENTS up, which it isn't doing it is just rounding

    Thanks

  6. #6
    Guest
    Try this.

    Code:
    Dim Equals As String
    Equals = Str(Val(Text3) + Val(Text2) + Val(Text1))
    
    Equals = Format(Equals, "0.00")
    Print Equals
    [Edited by Megatron on 08-08-2000 at 05:58 PM]

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Posts
    482
    EXCELLENT!
    THANKS


    U are truely the guru

Posting Permissions

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



Click Here to Expand Forum to Full Width