Click to See Complete Forum and Search --> : How can we determine the type of a control in VB


Ali Habib
March 21st, 2001, 05:48 AM
I need to determine the type of each control on the form. That is I need to check whether a control is commandButton or checkbox etc. Using the Controls collection I can traverse through all the controls on the form, but how can i check their types?

Ali.

shree
March 21st, 2001, 05:56 AM
Use TypeOf(). Be sure to use Is for comparison.


Dim aControl as Control
for each aControl in Controls
If TypeOf(aControl) is CommandButton then
MsgBox aControl.Name
End If
next