Click to See Complete Forum and Search --> : How can you determine the control type?


Raptors Fan
September 7th, 2001, 01:56 PM
Hi,

I'm passing a control in a function and I want to determine the control type, such as combobox, textbox, etc.

I set a variable as a control. I see a name property but that is the actual name give to the control and not the control type.

How can you determine the control type?

Many thanks,

RF

Andrew R.
September 7th, 2001, 02:09 PM
When you call your function you probably know which control you're sending.
So, creat your own enum and pass type of control as an additional parameter in function.
Or, save the type of the control in its 'Tag' property and then read it in the function.

DSJ
September 7th, 2001, 02:09 PM
private Sub Command1_Click()
SomeSub Command1
End Sub


private Sub SomeSub(c as Control)
If TypeOf c is CommandButton then
MsgBox "It's a command button"
End If
If TypeOf c is ListBox then
MsgBox "It's a listbox"
End If
'etc. etc. etc....
End Sub