How to get the type of a control

S

shapper

Hello,

I created 3 custom controls: A, B and C.
Given a control how can I get its type and check if it is of type A, B
or C?

Thanks,
Miguel
 
S

Scott M.

If A.GetType() = B.GetType() Then.....

....or...

If GetType(A) = GetType(B) Then....

....or....

Select Case A.GetType.Name
Case B.GetType.Name
' Do something

Case C.GetType.Name
' Do something

End Select
 
J

John MJ Gorter

maybe you could use the "IS" keyword/operator?


If A.GetType() = B.GetType() Then.....

...or...

If GetType(A) = GetType(B) Then....

...or....

Select Case A.GetType.Name
Case B.GetType.Name
' Do something

Case C.GetType.Name
' Do something

End Select
 
S

Scott M.

Yep, I realized that just as I was looking at my post. Replace "=" with
"Is" when checking a type against another type.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Get Controls 2
Get Parent Control 1
Find Control 1
Get control 2
Control 1
Find Control 2
Get Mime Type of File 4
Excel Typed text appears in wrong cell 0

Top