|
-
Jan 11th, 2007, 10:06 AM
#1
Thread Starter
Hyperactive Member
-
Jan 11th, 2007, 11:56 AM
#2
-
Jan 11th, 2007, 12:16 PM
#3
Hyperactive Member
Re: Random Order
Use this function:
VB Code:
Public Function intRandomBetween(lowerNum As Integer, higherNum As Integer) As Integer
intRandomBetween = Int((higherNum - lowerNum + 1) * Rnd + lowerNum)
End Function
With this code:
VB Code:
Dim i, rndm As Integer
Dim gend, nms As String: gend = "": nms = ""
Do While i < 26
rndm = intRandomBetween(1, 26)
If InStr(gend, "(" & rndm & ")") <= 0 Then
nms = nms & rndm & ", "
i = i + 1: gend = gend & "(" & rndm & ")"
End If
Loop
Label1.Caption = Mid$(nms, 1, Len(nms) - 2)
If you put that in a command button, or any object's click event or something of the sort, it'll set a caption to numbers 1 through 26 generated in random order for you, separated by commas.
Obviously, you could modify this accordingly to suit your needs and assign values in whatever order the numbers are generated, of course.
Last edited by BrendanDavis; Jan 11th, 2007 at 01:32 PM.
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
|