This is how I create textboxes at runtime:
I can handle these textboxes from my form class but how can I handle them from a module?Code:Public TextBox1 As TextBox() = New TextBox(26) {} Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim CNT As Integer = 0 Dim Y As Integer = 8 Dim Y2 As Integer = 8 While CNT < 26 TextBox1(CNT) = New TextBox TextBox1(CNT).Size = New System.Drawing.Size(40, 20) TextBox1(CNT).Text = vbNullString TextBox1(CNT).MaxLength = 2 If CNT >= 18 Then TextBox1(CNT).Location = New System.Drawing.Point(295, Y2) Y2 = Y2 + 20 Else TextBox1(CNT).Location = New System.Drawing.Point(130, Y) Y = Y + 20 End If Me.Controls.AddRange(New System.Windows.Forms.Control() {TextBox1(CNT)}) CNT += 1 End While End Sub
EDIT: Sorry, I can already handle them, forgot to use "Form1.Textbox1" instead of just "Textbox1". I must be working hard...![]()


Reply With Quote
