-
How to make a textbox array at Runtime ?
ie, I want to make some textboxes in arrays (say txtNAME(i) )
I tried this method
Set txtNAME1 = Controls.Add("VB.textbox", "txtNAME1"), it works.
But when I give
FOR I = 1 TO 10
Set txtNAME(i) = Controls.Add("VB.textbox", "txtno(i)")
NEXT
It gives “Not a legal object Name” error message
Anyone with a helping hand ?
Thanks in advance
-
You need to load the new control before referencing it.
The easiest way to do this (not always the fastest way)
is to create a single textbox on the form at Design time,
give it a name and an index = 0.
Runtime:
Code:
Dim lngIndex As Long
'The First control(0) was created at design time
For lngIndex = 1 To 9
Load ControlName(lngIndex)
'Place aligning code here (Left, Top, etc.)
ControlName(lngIndex).Visible = True
Next
This will create a control array of Controls 0-9
-
Hi miben
Thanks a lot.
It works fine.
Thank You
Jaggu
-