With VB 2010, for projects targeting .NET framework 4 and later, you can now do this:
Select Case msg.GetType()
Case GetType(ClassA)
End Select
In earlier VB versions, it didn't work because you couldn't compare two types with equality. You'd have to check if they point to the same reference using the Is keyword. It's not possible to do this in a Select Case, unless you use a property of the type like the Name or FullName for comparison, as suggested by Michael. You can use a combination of If and ElseIf though:
Dim type = msg.GetType()
If type Is GetType(ClassA)
...
ElseIf type Is GetType(ClassB)
...
...
End If
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…