Results 1 to 3 of 3

Thread: Rounding off differently, how I can it make........

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Rounding off differently, how I can it make........

    Hi All
    someone know how i can to round my values however when they have already value after comma larger from 0,2.

    e.g.

    normally rounded off : 5,44 to 5,00 | 6,67 to 7,00 | 1,53 to 2 etc, etc

    I want to make: 2,23 to 3,00 | 5,17 to 5,00 | 1,28 to 2,00 etc, etc

    hope, that this comprehensible what I want

    So, how it make? thanks in advance
    I know, I know, my English is bad, sorry .....

  2. #2
    Addicted Member
    Join Date
    Oct 2006
    Location
    Chennai, India
    Posts
    198

    Re: Rounding off differently, how I can it make........

    vb Code:
    1. Public Function roundDown(dblValue As Double) As Double
    2. On Error GoTo PROC_ERR
    3. Dim myDec As Long
    4.  
    5. myDec = InStr(1, CStr(dblValue), ".", vbTextCompare)
    6. If myDec > 0 Then
    7.     roundDown = CDbl(Left(CStr(dblValue), myDec))
    8. Else
    9.     roundDown = dblValue
    10. End If
    11.  
    12. PROC_EXIT:
    13.     Exit Function
    14. PROC_ERR:
    15.     MsgBox Err.Description, vbInformation, "Round Down"
    16. End Function
    17.  
    18. Public Function roundUp(dblValue As Double) As Double
    19. On Error GoTo PROC_ERR
    20. Dim myDec As Long
    21.  
    22. myDec = InStr(1, CStr(dblValue), ".", vbTextCompare)
    23. If myDec > 0 Then
    24.     roundUp = CDbl(Left(CStr(dblValue), myDec)) + 1
    25. Else
    26.     roundUp = dblValue
    27. End If
    28.  
    29. PROC_EXIT:
    30.     Exit Function
    31. PROC_ERR:
    32.     MsgBox Err.Description, vbInformation, "Round Up"
    33. End Function
    Regards
    Srinivasan Baskaran
    India

  3. #3
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    Re: Rounding off differently, how I can it make........

    How about this:

    dblValue=dblValue + 0.3

    Round as normal

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