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

Determining control array in a control collections

Status
Not open for further replies.

JBats

Programmer
Aug 3, 2003
127
PH
I created a collection of controls in my form. Now, read through each control of the form to get the control name and its index number. Not all the controls in my form was defined as control array. Now my problem is how can I determine if the control that was being read through my For...Next statement has an Array Number or None. Below is the code I created.

Dim oControl As Control
dim sParamName as string
dim iIndexNo as integer

For Each oControl In Controls
If TypeOf oControl Is TextBox Then
If oControl.Visible Then
sParamName = oControl.Name
iIndexNo = oControl.Index
End If
end if
Next

When the compiler read this statement below
iIndexNo = oControl.Index

it gets error when that control has no array element. How could I trap or identify if it has an array element or none.

Any help would be highly appreciated.



JBats
Good is not better if not than best...
 
A crude way is to play with the On Error Resume Next instruction and the Err.Number property.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
You could use the nz() function to change the null value into a zero. nz(oControl.Index,0).

Hope this helps,
DES
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top