楼主最近还看过
Private Sub Cmdset_Click()
Call diziq
If CStr(Val(setadout)) <> setadout Then Exit Sub
MSComm1.OutBufferCount = 0
MSComm1.InBufferCount = 0
devdatout = "7" + devdatout
fg:
MSComm1.Output = Chr(2) + devdatout + sumchk(devdatout)
tim = Timer
Do
If Timer > tim + 1 Then: Exit Do
Loop Until MSComm1.InBufferCount = 1
If MSComm1.Input = Chr(6) Then
MSComm1.InBufferCount = 0
Else
If MsgBox("置位不成功", vbRetryCancel + vbCritical) = vbCancel Then Exit Sub
If MsgBox("置位不成功", vbRetryCancel + vbCritical) = vbRetry Then GoTo fg
End If
outalarm.FillColor = QBColor(12)
End Sub
这是置位按钮函数
Private Sub Cmdreset_Click()
Call diziq
If CStr(Val(setadout)) <> setadout Then Exit Sub
MSComm1.OutBufferCount = 0
MSComm1.InBufferCount = 0
devdatout = "8" + devdatout
fg:
MSComm1.Output = Chr(2) + devdatout + sumchk(devdatout)
tim = Timer
Do
If Timer > tim + 1 Then: Exit Do
Loop Until MSComm1.InBufferCount = 1
If MSComm1.Input = Chr(6) Then
MSComm1.InBufferCount = 0
Else
If MsgBox("复位不成功", vbRetryCancel + vbCritical) = vbCancel Then Exit Sub
If MsgBox("复位不成功", vbRetryCancel + vbCritical) = vbRetry Then GoTo fg
End If
outalarm.FillColor = QBColor(10)
End Sub
这是复位按钮函数