Results 1 to 6 of 6

Thread: why am I rounding?

  1. #1

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    Label9.Caption = CLng(Text1) + CLng(Text2)
    Label9.Caption = Format(Label9.Caption, "###,###.##")

    text1 = 22.50
    text2 = 12.40

    label9 = 35

    What am I doing wrong?

    Thanks,
    Wayne

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    clng is rounding for you because long is a long integer. Try Cdbl to convert you text to doubles

  3. #3
    Hyperactive Member
    Join Date
    Apr 1999
    Location
    New Jersey
    Posts
    334

    problem?

    What's the problem?

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600
    Hi HeSaidJoe,

    The CLng Function is rounding your label values to Integers. Try this instead:
    Code:
    Label9.Caption = CSng(Text1) + CSng(Text2) 
    Label9.Caption = Format(Label9.Caption, "###,###.##")
    All the best.



  5. #5

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    Thanks all...I didn't realize lng was an integer.


  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I would use val, cuz it takes all values
    Label9.Caption = Format(VAL(Text1) + VAL(Text2) , "###,###.##")

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