adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149
See if this helps to create Dynamic.TextBoxes on a Form.
Public Class Form1
#Region "----===----===----===----- myCoolDYNAMICS -----===----===----===----"
Private Sub createCoolTextBoxes()
'// # at end of TextBox, location from Left to Right, location from Top to Bottom.
Dim iCoolNumberForName As Integer = 1, iLeftLocation As Integer = 5, iTopLocation As Integer = 5
'// create Dynamic.TextBox.
Dim txt As New TextBox With {.Name = "TextBox" & iCoolNumberForName.ToString, .Left = iLeftLocation, .Top = iTopLocation, .Text = .Name}
Me.Controls.Add(txt) '// add txtBox to Form.
iCoolNumberForName += 1 : iLeftLocation += 5 : iTopLocation += 25
txt = New TextBox With {.Name = "TextBox" & iCoolNumberForName.ToString, .Left = iLeftLocation, .Top = iTopLocation, .Text = .Name}
Me.Controls.Add(txt) '// add txtBox to Form.
iCoolNumberForName += 1 : iLeftLocation += 5 : iTopLocation += 25
txt = New TextBox With {.Name = "TextBox" & iCoolNumberForName.ToString, .Left = iLeftLocation, .Top = iTopLocation, .Text = .Name}
Me.Controls.Add(txt) '// add txtBox to Form.
'// etc./etc.
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
createCoolTextBoxes()
End Sub
End Class
As for getting values from your new TextBoxes, check out this recent post of mine . The second part of code, w/the sTemp &= CType(Me.Controls(<strong>"TextBox" & i</strong>.ToString), TextBox).Text ; i being iCoolNumberForName in the above code.
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384