-
Roundup in Visual Basic
I need to know wich is the round function in Visual Basic similar to Roundup of Microsoft Excel. ???
In Excel this function round the decimal values of this way:
Roundup(0.22,2)=0.22
Roundup(0.221,2)=0.23
Roundup(0.2201,2)=0.23
always to up !!!!!
This function exists in Visual Basic ????
Thanks and Regards
Sebastian
-
you can make a function like this:
Code:
Function Roundup(f As Single, precision As Integer) As Single
Dim f2 As Single
precision = 2
f2 = FormatNumber(f, precision)
If f > f2 Then f2 = f2 + 10 ^ -precision 'Maybe there's a better way for this...
Roundup = f2
End Function
'Then use:
Private Sub Form_Load()
MsgBox Roundup(0.2201, 2)
End Sub