In this lesson we teach you how to use If – Then – Else statements to control which code is run under which conditions.
If you want to test the object type you can use the TypeOf keyword:
If TypeOf swApp Is SldWorks.SldWorks Then MsgBox "This is an ISldWorks object."
This will be particularly useful when programming with the SolidWorks API if you need to test for an object’s type.
Using Select Case to test for a condition is faster than using several If – Then statements in a row. This is because when using Select Case, the compiler jumps directly to the outcome of the evaluated expression.
Select Case is also limited to evaluating one condition, whereas with ElseIf, multiple conditions can be tested.