|
-
August 21st, 2002, 01:14 PM
#1
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
-
August 21st, 2002, 04:25 PM
#2
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|