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
            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
5 Years
Discussion Span
Last Post by WaltP

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.