Public Function RoundUp(ByVal num As Double) As Integer
Try
'Temp variable to hold the decimal portion of the parameter
Dim temp As Double
'Get the decimal portion
temp = num - Math.Truncate(num)
'If there is a decimal portion then we add 1 to force it to round up
num = IIf(temp > 0, num + 1, num)
'return the truncated version of the double which should be the number rounded up
Return Math.Truncate(num)
Catch ex As Exception
MessageBox.Show("Error occured in: " & ex.StackTrace & vbCrLf & vbCrLf & "Error: " & ex.Message, _
"Error.", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return Nothing
End Try
End Function
|