PDA

Click to See Complete Forum and Search --> : rounding


raicheman
Jan 17th, 2000, 05:50 AM
In C++ there is a ceiling function that allows one to always round a number up. Example: if the number is 11.1 ceiling will round to 12. I know about Round(number,0) and Format(number,"###.") , but these will round a number less that .5 down to the next lowest integer. Is there some sort of ceiling function in VB

------------------

Jan 17th, 2000, 06:12 AM
Try this code:-

Private Sub rounder(ByVal number As Double)
Dim place As Integer
If InStr(number, ".") <> 0 Then
place = InStr(number, ".")
number = Left(number, place)
number = number + 1
MsgBox number
Else
End If


Glenn Harwood
End Sub

Jan 17th, 2000, 06:14 AM
Sorry, slight typo...try this

Try this code:-

Private Sub rounder(ByVal number As Double)
Dim place As Integer
If InStr(number, ".") <> 0 Then
place = InStr(number, ".")
number = Left(number, place)
number = number + 1
MsgBox number
Else
End If
End Sub

Glenn Harwood

LG
Jan 17th, 2000, 06:40 AM
Is it not too much of coding for this?

Why don't you just + 0.5 to the number to be rounded?

Looks shorter