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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I check if a control element exists?

Status
Not open for further replies.

SirPaladin

Programmer
Jul 9, 1999
32
0
0
US
Is there a way to verify that a control array element exists before I use it? I ask because when I'm binding my controls to an ADO recordset, it would be easier if I could use a FOR NEXT loop, but I have to take into account that not necessarily every element has been used. For instance, Text1(0) - Text1(7) might be valid, as well as Text1(9) - Text1(12), but Text1(8) no longer exists.
 
Dim ctl As Control
Dim lnIndex As Long
For Each ctl in ControlArrayName
lngIndex = ctl.Index ' in case you care about index
if ctl.yadda =<> Then exit for ' if found
Next
if ctl Is Nothing then ' Was Set = Nothing by last For/Each
...reached end of For Each
Else
....ctl refers to a control
End if Compare Code (Text)
Generate Sort in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top