Results 1 to 4 of 4

Thread: 1 duh question

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441
    1) How come when I try to do a formula like,

    50 * (3/100), vb returns 2 and not 1.5? How can I make it return 1.5? I know it is rounding, but I can't figure out how to stop it from doing so...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  2. #2
    Hyperactive Member
    Join Date
    May 2000
    Location
    Or
    Posts
    316
    It works for me if I declare the variable to hold the result as a double.

    Code:
    Private Sub Command1_Click()
    
    Dim dbl_rec As Double
    dbl_rec = 50 * (3 / 100)
    MsgBox Val(dbl_rec)
    
    End Sub
    Hope this helps.

  3. #3

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    You got it...

    I was using a long varaible to hold the value. When I set it to double, I got my desired result. Thanks...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

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