Hi eveyone,
I have a few labels in a panel and found this bit of code...
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim RndGen As New Random
For Each ctrl As Control In Panel1.Controls
Dim lbl As Label = TryCast(ctrl, Label)
If lbl IsNot Nothing Then
lbl.Text = RndGen.Next(1, 45).ToString
End If
Next
End Sub
what i would like to do is , put the text values into an array. So that i can evaluate them to see if any are equal to each other.
if 2 are both the same, then lose both . The idea is to end up with random single number all different.
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim RndGen As New Random
Dim lblarray(21) As String
For Each ctrl As Control In Panel1.Controls
For P As Integer = 0 To 21
Dim lbl As Label = TryCast(ctrl, Label)
If lbl IsNot Nothing Then
lbl.Text = RndGen.Next(1, 45).ToString
End If
lblarray(P) = lbl.Text
Next
Next
End Sub
I have done the above code, but it is not quite working out...
Many thanks for reading.