creating objects at runtime, on the fly

fguihen

Junior Contributor
Joined
Nov 10, 2003
Messages
248
Location
Eire
i have to create a number of objects. they could be forms or any object really, but i want to know is how do i create a new object when a user clicks a button? the user could click the button many times, creating many objects, and i dont want to limit the user by only declaring a set number of objects
 
Here's an example of creating a form from scratch and adding a textbox to the form

Visual Basic:
        Dim frm As New Form
        frm.Name = "frmCreated"
        frm.Text = "Created Form"

        Dim tb As New TextBox
        tb.Name = "tbTest"

        frm.Controls.Add(tb)
        frm.Show()

Of course you can set other properties of the form and textbox such as size, location, borderstyle, etc.
 
Back
Top