Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Creating a Control array at run time?

Hi,

I would like to create a 'planner'/gannt type effect and I thought I could use a control array to do this. Simply creating labels and/or pics at run time....but how?

I feel I should know how to do this ...

Any ideas..

Thanks

0
jonesgj
Asked:
jonesgj
1 Solution
 
hongjunCommented:
Dynamically create textboxes at runtime example. For labels, pics, etc, do similar.

Try below example.

1. Add 1 textbox to a new project
2. Change the index property of the textbox to value 0
3. Then add the below code to the form code

Option Explicit

Private Sub Form_Load()
   Dim i As Integer
   Dim intAdd As Integer
   
   intAdd = 2 ' add 2 more textboxes
   For i = 1 To intAdd
       Load Text1(i)
       Text1(i).Top = Text1(i - 1).Top + 1000
       Text1(i).Visible = True
   Next
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Dim i As Integer
   Dim intAdd As Integer
   
   intAdd = 2 ' add 2 more textboxes
   
   For i = 1 To intAdd
       Unload Text1(i)
   Next
End Sub


What the above code does is to dynamically add 2 textboxes at runtime. Note that there need to have at least 1 textbox at design time. If you do not want any textbox at all when the program is to be run, then you can simply set the visibile property to false.


Good Luck
hongjun
0
 
jonesgjAuthor Commented:
Thanks ....

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now