I'm trying to make a Bulls and Cows type game, I was able to do it fairly easily with javaScript, but VB is killing me. I can get the array 5 slots long with random numbers, unfortunately they're all repeats. when I try getting no repeats I run into infinite loops, exponentially increasing array lengths, and just plain old arrays with 5 numbers randomly generated, but with repeats.
I'm trying to do this with loops, in JS I did it using regular expressions, but I have no clue how to use them in VB.
Here's an example of my code.
Please note, I'm a beginner - so please be patient. Thanks for anyhelp.
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
	
		
			
		
		
	
				
			I'm trying to do this with loops, in JS I did it using regular expressions, but I have no clue how to use them in VB.
Here's an example of my code.
Please note, I'm a beginner - so please be patient. Thanks for anyhelp.
			
				VB.NET:
			
		
		
		Public Class Form1
    Dim intRand(0) As Integer
    Dim RandomClass As New Random
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ReDim intRand(0)
        intRand(0) = GenNum()
        Dim intTempRand As Integer = 0
        Dim intCounter As Integer = 0
        '     lst5Rand.Items.Clear()
        'Loop Outter
        For i As Integer = 0 To 4
            'Loop Inner
            intTempRand = GenNum()
            For y As Integer = 0 To intRand.Length
                If intTempRand = intRand(y) Then
                    lbl1.Text = "Duplicate"
                    Do While intTempRand = intRand(y)
                        intTempRand = GenNum()
                    Loop
                ElseIf intTempRand <> intRand(y) Then
                    lbl1.Text = Convert.ToString(intRand.Length)
                    ReDim Preserve intRand(intRand.Length + 1)
                    intRand(i + 1) = intTempRand
                End If
                ReDim Preserve intRand(intRand.Length + 1)
            Next
            lst5Rand.Items.Add(intRand(i))
        Next
    End Sub
    Private Function GenNum() As Integer
        Return RandomClass.Next(0, 4)
    End Function
End Class 
	 
 
		
 
 
		 
 
		 
 
		 
 
		 
 
		