|
-
Jul 7th, 2006, 02:02 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Rounding (Simple question)
Hi all,
I'm trying to make a program generate a random number and then output it. The only problem is, the number needs to be fairly big, so an Integer doesn't work (it creates overflows). I can use a double, but then it outputs a long line of numbers after the decimal point. How can I make it round the number?
Code:
Private Sub GenRan_Click()
Dim RI As Double
Dim GN As Double
If RanIn.Text = "" Then
MsgBox "You must enter a value!", vbExclamation, "Error"
Exit Sub
End If
Randomize
RI = RanIn.Text
GN = RI * Rnd
MsgBox GN, vbInformation, "Your number is..."
End Sub
Thanks all
Last edited by BubbleLife; Jul 7th, 2006 at 02:06 PM.
-
Jul 7th, 2006, 02:05 PM
#2
Hyperactive Member
Re: Rounding (Simple question)
Round(Number,Number of values after decimal point)
Or you can use the long variable type
-
Jul 7th, 2006, 02:06 PM
#3
Thread Starter
Addicted Member
Re: Rounding (Simple question)
Splendid! Thank you very much. How high can "long" go up to?
-
Jul 7th, 2006, 02:10 PM
#4
Hyperactive Member
Re: [RESOLVED] Rounding (Simple question)
-2,147,483,648 to 2,147,483,647, or 4 bytes
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
|