Jarod,
Use TypeOf Is:
Dim c As control
If TypeOf c Is ComboBox Then
Dim combo As ComboBox = DirectCast(c, ComboBox)
ElseIf TypeOf c Is TextBox Then
Dim combo As TextBox = DirectCast(c, TextBox )
End If
You can use Object.GetType along with the GetType function, if you want to
know specifically if its the type. I prefer the TypeOf operator as it
supports classes derived from the listed class.
If c.GetType() Is GetType(ComboBo x) Then
Dim combo As ComboBox = DirectCast(c, ComboBox)
ElseIf c.GetType() Is GetType(TextBox ) Then
Dim combo As TextBox = DirectCast(c, TextBox )
End If
Hope this helps
Jay
"Jarod_24" <ja******@hotma il.com> wrote in message
news:ef******** *************** *******@news.te ranews.com...
I got a object of type 'Control' passed as a argument to a subroutine of
mine. The object is either a Combobox or a TextBox.
I thought the .GetType could be used to check what type of object it was,
but i haven't had any luck.
In Java you got the instanceOf() operator to do this. What's the equilant
in VB.net?