|
-
Mar 17th, 2007, 12:41 PM
#1
Thread Starter
New Member
[2005]
In this simple Lottery simulation, how do I ensure that a number is not generated twice? I am assuming I need to search the array to verify that there are no equal values but how? Thanks much.
Public Class Lottery
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim counter As Integer = 0
Dim y As Integer
Dim instance As New Random()
Dim myArray(5) As Integer
While counter < myArray.Length
y = instance.Next(1, 37)
myArray(counter) = y
counter = counter + 1
TextBox1.Text = TextBox1.Text & y & (" ")
End While
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|