Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleAccess controls by their names as text strings
Keywordscontrol, controls, name
CategoriesControls
 
The Controls collection uses the controls' names as keys. You can use that to get a control and access its properties using its name.

Normally you wouldn't bother, you would just set the control's properties. However, you may need to find a control using a name entered by the user, calculated, or otherwise unknown at design time.

The following code displays the captions of three controls, two of which are in a control array.

 
Private Sub Form_Load()
    lblCaption(0).Caption = Controls("Label1")(0).Caption
    lblCaption(1).Caption = Controls("Label1")(1).Caption
    lblCaption(2).Caption = Controls("Command1").Caption
End Sub
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated