Yes you can. Try the following Code
Dim obj As VB.TextBox
Dim x As Long
For x = 1 To 10
Set obj = Me.Controls.Add("VB.TextBox", "txt" & x)
obj.Visible = True
obj.Width = 2500
obj.Height = 258
obj.Top = 60 + ((x - 1) * obj.Height)
obj.Text = "I am New TextBox Number: " & x
Next
Set obj = Nothing
----- Original Message -----
From: "Alessandro Bernardi" <abernardi@b...>
To: "professional vb" <pro_vb@p...>
Sent: Friday, January 17, 2003 1:55 AM
Subject: [pro_vb] Can I create objects run-time? (eg a textbox)
> In example I don't know how many textboxes I need for my application and I
> would like to draw my form once defined how many I need.
>
> How can I do? (either in vb6 or vb.net)
> with vb6 I tried using an array of textboxes... something like this:
>
> for r = 0 to 9
> dim tb(r) as new textbox
> tb(r).top = r * 10
> rb(r).height = ...
> ...
> next r
>
> but... nothing... why?
>
> So I tried to put a well defined textbox (tbGood)
>
> dim tb(r) as new tbGood
>
> but...
>
> is there a way to do that?
> Now I'm migrating to vb.net and I (sadly) can't use the objects' array (or
> probably it's a fault of mine, but i think i should use old object that
are
> ther just for compatibility)
>
> thank you in advance.
> Ale.
>
>
>
>
>