|
-
Mar 28th, 2001, 09:40 AM
#1
Thread Starter
Junior Member
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
-
Mar 28th, 2001, 10:17 AM
#2
Addicted Member
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
Always looking for a better and faster way!
-
Mar 28th, 2001, 11:55 PM
#3
Thread Starter
Junior Member
Hi miben
Thanks a lot.
It works fine.
Thank You
Jaggu
-
Mar 29th, 2001, 02:21 AM
#4
Addicted Member
No problem
Always looking for a better and faster way!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|