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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top