My problem is after I created 5 rows of text boxes, I want to add random numbers to all of the text boxes in one time when I click the button.
Does anybody know how to solve this problem??

Here are my coding to create text box dynamically:

Private Sub btnAdd5Row_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddFiveRow.Click

        For Me.count = count To 5
   
            Dim myTextBox2 = New TextBox
            With myTextBox2
                .Name = "txtNum" & count
                .Size = New Size(50, 26)
                .Location = New Point(x, y)
                .Font = txtNum1.Font
                .TextAlign = HorizontalAlignment.Center
                .MaxLength = 4
                Controls.Add(myTextBox2)
            End With

    End Sub

Here is the random number coding.

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim RandomClass As New Random
        Dim RandomNumber As Integer
        RandomNumber = RandomClass.Next(0, 9999)
        



    End Sub

Create a loop to loop through each text box.
Set the 'current' text box TEXT value to the Random Number generated

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.