I have items in a control array which are made when the program is running. Is there a way for me to check if a certain one exists?
Printable View
I have items in a control array which are made when the program is running. Is there a way for me to check if a certain one exists?
while creating controls dynamically you know what you create Right! then why do you want to check again what controls available.
I mean, you know what you are doing? So, I think there is no need to check once again.
the code needs to go:
VB Code:
if [item] exists then 'things end if
VB Code:
Dim ctl As Control For Each ctl In Controls If ctl.Name = <the name of the control array> Then If ctl.Index = 4 Then ' or whichever one you are looking for MsgBox "it exists" End If End If Next
or, to save looping through unnecessary controls:VB Code:
Dim ctl As Control For Each ctl In ctlArray If ctl.Index = 4 Then ' or whichever one you are looking for MsgBox "it exists" Exit For End If Next ctl