0

I'm trying to create a non-definite number of textboxes in my program, place them in my form and later retrieve information from them.

I want to add one textbox at a time when I press a button.

I can add one textbox like this:

Private Sub Addsystem_Click(sender As Object, e As EventArgs) Handles Addsystem.Click
    Form2.ShowDialog()
    Dim mytext As New TextBox()
    mytext.Location = New Point((OBstartfreq.Location.X), (OBstartfreq.Location.Y + 30))
    Me.Controls.Add(mytext)
End Sub

Like this I can get only the text from the mytext textbox.

How can I make it that every time I press the button a new textbox will appear?

4
  • 3
    You have already the code that creates the textboxes. The only problem is that they are one on top of the other, so you see just one. You need to adjust the location value. By the way, what is the purpose of that Form2.ShowDialog ? Commented Nov 2, 2016 at 15:29
  • 3
    ...or use a TableLayoutPanel Commented Nov 2, 2016 at 15:30
  • 1
    For example, take a look at this post. Commented Nov 2, 2016 at 15:36
  • the Form2.ShowDialog is for something diffrent. it does not affect anything here. i know i can create multiple textboxes like this but i dont know how to access them later in my code, for example i need to get the text from them later and use it in another place. Commented Nov 3, 2016 at 10:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.