Results 1 to 4 of 4

Thread: round function

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2000
    Posts
    23
    Hello
    can anyone tell me if the result of a calculation returns a value of say 62.05 (could be anything)is it possible to use the round function to make the result always round up eg:63 rather than 62?
    Thanks

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Why not do this?
    Code:
    Rounded = Int(Number + 1)
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    Guest
    One way to always make a real value round up is to use the Int() function (which always rounds down on positive numbers) and just add one to your result. For example:

    Code:
    Dim dblNumber As Double
    Dim intResult As Integer
    
    dblNumber = 62.05
    
    intResult = Int(dblNumber) + 1
    
    MsgBox intResult  '  Displays 63
    Paul

    PS - Looks like oetje and I posted the same reply at the same time! :P

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Something to be aware of if you are wanting to
    keep the whole number and disregard the .xx
    Code:
    Dim x as double
    x = 62.65   'if .xx more than .5x
    
    msgbox round(x) + 1 'returns 64
    msgbox cint(x) + 1  'returns 64
    msgbox fix(x) + 1   'returns 63
    
    fix always reverts to the whold while cint,round, will
    go higher if fraction over 5
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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