jxharding
asked on
round UP to next biggest .5 or 0, e.g. 20.3-->20.5 & 28.8-->30, am i bound to a case statement? i tried good few functions already
hi, i need help on a round function and all it needs to do is always ROUND UP to the next half.
functions i've tried:
Private Function MyRound(ByVal aNumber As Single) As Single
If aNumber < 0 Then
Return CSng(Microsoft.VisualBasic .Fix((aNum ber - 0.25) * 2) / 2)
Else
Return CSng(Microsoft.VisualBasic .Fix((aNum ber + 0.25) * 2) / 2)
End If
End Function
Public Function Round5(ByVal d As Double) As Double
Return Math.Round(d * 2) / 2
End Function
am i bound to making a case statement, cause id absolutely learn nothing from it.
thanks!
functions i've tried:
Private Function MyRound(ByVal aNumber As Single) As Single
If aNumber < 0 Then
Return CSng(Microsoft.VisualBasic
Else
Return CSng(Microsoft.VisualBasic
End If
End Function
Public Function Round5(ByVal d As Double) As Double
Return Math.Round(d * 2) / 2
End Function
am i bound to making a case statement, cause id absolutely learn nothing from it.
thanks!
ASKER
hi ronaldbiemans
sorry , i made a error in the heading.
it only needs to update to the next half, "28.8-->30" should be 28.8-->29.0
thus if the first decimal place is bigger than 0 and smaller than 5, the first decimal place must then be .5
else
if the first decimal is bigger than 5, then the non decimal must +1 and, the decimal must be .0.
thanks!
sorry , i made a error in the heading.
it only needs to update to the next half, "28.8-->30" should be 28.8-->29.0
thus if the first decimal place is bigger than 0 and smaller than 5, the first decimal place must then be .5
else
if the first decimal is bigger than 5, then the non decimal must +1 and, the decimal must be .0.
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
oh! and the tbNum is a text field in which i take an input of the number to test...
a question
24.4 -> 20
25.0 -> 30