Results 1 to 4 of 4

Thread: [RESOLVED] Rounding (Simple question)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Resolved [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.

  2. #2
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Re: Rounding (Simple question)

    Round(Number,Number of values after decimal point)
    Or you can use the long variable type

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2005
    Posts
    248

    Re: Rounding (Simple question)

    Splendid! Thank you very much. How high can "long" go up to?

  4. #4
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    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
  •  



Click Here to Expand Forum to Full Width