Get Control Type

  • Thread starter Thread starter Beebs
  • Start date Start date
B

Beebs

I've searched the newsgroups, but to no avail. I need to get the type
of a control, such as Button, or Label, but when I try to use the
GetType call, it doesn't seem to work like I need it to...I'm doing
something like:

For Each ctrl As Control In Parent.Controls
If ctrl.GetType Is Button Then
 
Any idea why I would be getting the error "An unhandled exception of
type 'System.NullReferenceException' occurred..." on this line of
code:

For Each ctrl As Control In Parent.Controls
 
Probably because Parent = Nothing

Beebs said:
Any idea why I would be getting the error "An unhandled exception of
type 'System.NullReferenceException' occurred..." on this line of
code:

For Each ctrl As Control In Parent.Controls
 
I believe you're right. I changed it to Me.Controls and all seems to
be working fine now.
 
Back
Top