For object variables, use TypeOf ... Is
:
If TypeOf VarName Is TypeName Then
''# ...
End If
For example:
Dim fso As New Scripting.FileSystemObject
If TypeOf fso Is Scripting.FileSystemObject Then
Debug.Print "Yay!"
End If
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…