Generate random integers

eagle

Active member
Joined
Mar 8, 2005
Messages
28
Programming Experience
1-3
Can someone help me? I want to generate random 4 integers (1,2,3 and 4) but I want them each time in a different order. The problem is, when the integer already exists, he should do the function again, and he does that, but in the end, he takes his double values back. My exit function doesn't help :confused: so my code. Hope that somebody can help. Thx

Private rand As Random

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

MsgBox(BerekenItem)

MsgBox(BerekenItem)

MsgBox(BerekenItem)

MsgBox(BerekenItem)

End Sub

Private Function BerekenItem()

rand =
New Random

Dim i As Integer = rand.Next(0, 4)

For Each Int As Integer In arlRandom

If i = Int Then

BerekenItem()

Exit Function

End If

Next

arlRandom.Add(i)

Return i

End Function


 
Top Bottom