Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
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
 
 
 
TitleSee if a control exists
Keywordscontrol, exists
CategoriesControls
 
Use On Error Resume Next. Then try to access one of the control's properties and check Err.Number to see if an error occurred.

Note that you can use UBound to find the upper bound of a control array. For example, if lblName is a control array, then lblName.LBound and lblName.UBound give the array's lower and upper bounds.

However, this does not mean every index is defined in between. Controls with indexes 0 and 5 may be loaded while no other controls are loaded.

 
Private Sub cmdTest_Click()
Dim idx As Integer
Dim lft As Single

    idx = CInt(txtIndex.Text)
    On Error Resume Next
    lft = lblControl(idx).Left
    If Err.Number <> 0 Then
        MsgBox "This control does not exist."
    Else
        MsgBox "This control is loaded."
    End If
End Sub
 
Formatted by Neil Crosby
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated