How can you determine the control type?
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
Re: How can you determine the control type?
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.
Re: How can you determine the control type?
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