Hi Guys,
I need some urgent help..
My requirement is to create dynamic text boxes during run time.
it shld b like this: when i click a button a text box shld b created and upon entering a value it shld be saved in access database.
appreciare ur help and quick responce.

regards,
vammy

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([B]"TextBox" & i[/B].ToString), TextBox).Text ; i being iCoolNumberForName in the above code.

Hi Adam,
Thnks for the solution.It worked for me.
and also thnks you codeorder for ur intervention here,.thanks alot guys,

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.