' TAMS 1887 USB Switch Controller ' Readback the position of a switch Imports VBexamples.tamsSC Public Class Example4 Sub example4() Dim handle As IntPtr Dim position As Integer handle = tamsSCstart("") If INVALID_HANDLE_VALUE = handle.ToInt32 Then MsgBox(tamsSCerror(), MsgBoxStyle.OKOnly, "Error") Exit Sub End If ' Read back the position of switch 4 tamsSCreadbackSwitch(handle, SWITCH_4, position) ' position is now POSITION_A or POSITION_B, also known as POSITION_1 or POSITION_2. ' If position = POSITION_A Then ... ' Optionally, with error checking. If FAIL = tamsSCreadbackSwitch(handle, SWITCH_4, position) Then MsgBox(tamsSCerror(), MsgBoxStyle.OKOnly, "Error") Exit Sub End If tamsSCend(handle) End Sub End Class