I have a question about repeating code. I made an example with a Random Number Generator
Public Class Form1
Dim Random As New Random
Dim Value(20) As Integer
Dim Number As Integer
Private Sub Bt_Random_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Random.Click
For i = 1 To 6 Step 1
Number = Random.Next(60)
Value(i) = Number
Next
Label1.Text = Value(1)
Label2.Text = Value(2)
Label3.Text = Value(3)
Label4.Text = Value(4)
Label5.Text = Value(5)
Label6.Text = Value(6)
Label7.Text = Value(7)
Label8.Text = Value(8)
Label9.Text = Value(9)
Label10.Text = Value(10)
Label11.Text = Value(11)
Label12.Text = Value(12)
Label13.Text = Value(13)
Label14.Text = Value(14)
Label15.Text = Value(15)
Label16.Text = Value(16)
Label17.Text = Value(17)
Label18.Text = Value(18)
Label19.Text = Value(19)
Label20.Text = Value(20)
End Sub
End Class
My question is: How can I UN-repeat the code so many times like this example? Thanks!
I just tried to make loops with For & Next, but didn't work :(