Public Class Form1
Dim B(4, 4) As Label
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To 4
For j As Integer = 0 To 4
B(i, j) = Me.Controls("Label" & i * 5 + (j + 1))
B(i, j).BackColor = Color.SkyBlue
Next
Next
For i As Integer = 0 To 4
For j As Integer = 0 To 4
B(i, j).Left = j * 50
B(i, j).Top = i * 50
Next
Next
Randomize()
Dim a As Integer
For i As Integer = 0 To 4
For j As Integer = 0 To 4
a = Int(Rnd() * 49) + 1
B(i, j).Text = a
Next
Next
Label26.Text = ""
Label26.BackColor = Color.Yellow
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Randomize()
Dim c As Integer
Dim d As String = ""
c = Int(Rnd() * 49) + 1
d = c & ", "
Label26.Text = Label26.Text & d
For i As Integer = 0 To 4
For j As Integer = 0 To 4
If B(i, j).Text = c Then
B(i, j).ForeColor = Color.Red
End If
Next
Next
End Sub
End Class
|