Click to See Complete Forum and Search --> : Creating controls dynamicaly


Jerislav
October 29th, 1999, 08:31 AM
How to create controls dynamicaly, and latter to use them trough array.

Please email answer to jbobic@diana.zesoi.fer.hr

Thanks

rajga
October 29th, 1999, 07:18 PM
Hi,
Have the desired control with index 0. To load controls dynamically call "LOAD" control function with a new index. For example,
lets say we have a Textbox control txtCntrl indexed 0 at design time.
At run time u say
..........
........
Load txtCntrl(1)
.......
...........
in the similar way u unload the controls.
Does that answer u'r question

October 31st, 1999, 06:36 PM
VB 6 also allows to add controls dynamically at run time without need to have an array. The example of adding Text Box:

private Sub Form_Load()
Form1.Controls.Add "VB.TextBox", "txtMyText"
With Form1!txtMyText ' you can also use next sintax
'With Form1.Controls("txtMyText")
.Visible = true
.Top = 500
.Left = 1000
.Width = 2000
.Height = 315
.Text = "It Works!"
End With
End Sub



Just paste this code into empty form and run.
HTH
Vlad