Results 1 to 6 of 6

Thread: Need the simple Random code

  1. #1
    Stiletto
    Guest

    Need the simple Random code

    Hey, I need the simple Random function.
    Can ne post it for me?
    tnx

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    MSDN :

    To produce random integers in a given range, use this formula:

    Code:
    Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
    Here, upperbound is the highest number in the range, and lowerbound is the lowest number in the range.

    something like that ?
    -= a peet post =-

  3. #3
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    To get you started:

    VB Code:
    1. Private Function Random(ByVal Min As integer, ByVal Max As integer) As Integer
    2.     Randomize
    3.     Random = Int((max - min + 1) * Rnd + min)
    4. End Function

  4. #4
    Stiletto
    Guest
    No, I mean something like get a random number between 1 to 10...
    ?

  5. #5
    Hyperactive Member kourosh's Avatar
    Join Date
    Aug 1999
    Location
    Vancouver, British Columbia, Canada
    Posts
    256
    Randomize

    int((10-1+1)*rnd+1)
    ===========================
    Kourosh Gonabadi
    VB Programmer
    C++ Newbie
    Graphic Designer
    ===========================

  6. #6
    Matthew Gates
    Guest
    VB Code:
    1. Private Sub Command1_Click()
    2.     Randomize Timer
    3.     Msgbox Int((Rnd * 10) + 1)
    4. 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
  •  



Click Here to Expand Forum to Full Width