42
Sample program
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If Not Command4. Enabled Then
Cancel = True
Exit Sub
End If
'Reset 8527 to local at finish of form
If Command1.Enabled Then
Call SendComm("RESET")
Call SendComm("KEYLOCK=OFF")
Call SendComm("REMOTE=OFF")
End If
Call CloseComm ‘Close port
End
End Sub
'Start of test
Private Sub Command2_Click()
Dim szBuf As String, nSTB As STB8527_ID
StopFlag = Flase
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = True
Command4.Enabled = False
'Confirm status before start
If SendComm("STATUS?", szBuf) = False Then GoTo Exit_Command2_Click:
If ErrorHandler(szBuf) = False Then GoTo Exit_Command2_Click:
szBuf = "&H" & szBuf
If IsNumeric(szBuf) = False Then GoTo Exit_Command2_Click:
nSTB = CLng(szBuf)
If (nSTB And sREADY) = 0 Then
MsgBox "Can not START.", vbCritical
GoTo Exit_Command2_Click:
End If
'RESET command
If SendComm("RESET", szBuf) = False Then GoTo Exit_Command2_Click:
If ErrorHandler(szBuf) = False Then GoTo Exit_Command2_Click:
'START command
If SendComm("START", szBuf) = False Then GoTo Exit_Command2_Click:
If ErrorHandler(szBuf) = False Then GoTo Exit_Command2_Click:
Do
DoEvents
sWait 0.5 'weight of 500ms