Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does a control exist?

Status
Not open for further replies.

samshiell

Programmer
Mar 12, 2001
26
GB
Hi

How can I find out programmatically if a control exists on a form?

I'm writing a generic procedure to which a form is passed as a "FORM" object,and I need to know whether a tabstrip exists on the form

Cheers
 
Code:
Dim C As Control
For Each C In Me.Controls
    If TypeOf C Is TabStrip Then
        Debug.Print C.Name & " is a tabstrip"
    End If
Next C
 
Cheers,

Now you've pointed this out it's obvious

Thanks

Sam
 
You can loop thru the Controls collection that exists for every form. Something like the following


Public Function CheckForTab (OnForm as Form) as Boolean

Dim Cntl as Control
Dim TabExists as Boolean

TabExists = false
For Each Cntl in OnForm.Controls
If (TypeName(Cntl) = "TabStrip") Then
TabExists = True
End If
End If

CheckForTab = TabExists

End Function
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top