×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Microsoft: FoxPro FAQ

## Usefull Functions & Procedures

 How to create UNIQUE RANDOM Numbers ? by ramani faq184-793 Posted: 4 Jun 01 You can cut & paste the following code and save the file as GenRand.Prg******************************************************* FUNCTION NAME ... GenRand** Author .......... Subramanian.G, FoxAcc**        .......... ramani_g@yahoo.com** Purpose ......... Generates required number of **                   Unique random numbers (nHowMany) **                   between the nLow & nHigh passed ** HowRun........... DO GenRand WITH nHigh,nLow,nHowMany**       ... or..... =GenRand(nHigh,nLow,nHowMany)** Limitations...... Size limited by Array ******************************************************* FUNCTION GenRandPARAMETERS nLow, nHigh, nHowMany** Exit the function if improperly calledIF PARAMETERS() < 3   WAIT "PARAMETERS ERROR"   RETURN .f.ENDIFIF nLow > nHigh OR nHowMany < 1 OR nHowMany > (nHigh-nLow)   WAIT "PARAMETERS ERROR"   RETURN .f.ENDIF**PUBLIC nRandArray(nHowMany)LOCAL nMyRand, nCount, nDuplicatenCount = 1nDuplicate = 0DO WHILE nCount < nHowMany    nMyRAND = INT(((nHigh-nLow+1)* RAND() ) + nLow)    nDuplicate = ASCAN(nRandArray,nMyRand)    IF nDuplicate # 0       LOOP    ENDIF    nRandArray(nCount) = nMyRand    nCount=nCount+1ENDDORETURN .t.************************************************************ Ramani  (Subramanian.G), FoxAcc, ramani_g@yahoo.com** EOF**********************************************************Evaluate this to make others know how useful is this Back to Microsoft: FoxPro FAQ Index Back to Microsoft: FoxPro Forum

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!