Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a Control Array at Run Time
Message
General information
Forum:
Visual Basic
Category:
ActiveX controls
Miscellaneous
Thread ID:
00149272
Message ID:
00149295
Views:
17
>I wish to create a control array at run time, with or without having a first control placed onto my form. Here is an example :
>
>Consider creating an array of option butons.
>I read a recordset, containing payment modes (i.e. Card, Check, Cash,...). i don't know at first how items there are into the recordset.
>I want to use recordcount to set the max items into my array.
>And I want to set payment text to the caption, and key to the index, i.e. Cash, 2, Check, 3, and so on.
>
>I've look at MS Online Books, but did not find anything.
>
>Help would be highly appreciated

If you use VB5, place a control (for example a text box) on your form with the index set to 0 (or something else different than null). Then when you need a new control, you use the following syntax:
Load Text1(1)
Text1(1).Top = Text1(0).Top + Text1(0).Height + 120
Text1(1).Visible = True
Your new control will have the same properties as the first one on your form except that the index will be the one you gave on the load statement and it will be invisble.

The same way you can unload the controls you created by using Unload Text1(1).

If you use VB6, I have read that you can create a new control on form without already having one instance created but I didn't know more at that time.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform