Well, in this case if the MainView is your class, then I would create a Generic class which would then allow you to work with a strong-typed value all the time...or you could have a type property on the MainView class that tells you what type it is. This could turn into a REALLY deep and complicated post since there are a lot of avenues to travel. But let's stick to the simple road If you are in control of the MainView class, then create a enum and test on the type:Public Enum MyGridType As Integer
CardView = 0
GridView = 1
End Enum
Public Class MainView
Inherits Whatever
Private _ItemType As MyGridType = MyGridType.CardView
Public Property ItemType As MyGridType
Get
Return _ItemType
End Get
Set (Byval value as MyGridType)
_ItemType = value
End Set
End Property
End Class
Then, you can test on the item type (which would reduce the overhead):
Select Case MainView.ItemType
Case MyGridType.GridView
'-- Add your code
Case MyGridType.CareView
'-- Add your code
End Select
Generics would be another route, but would probably require that you change a bit of code and it is a bit more complicated.