51和VB數(shù)字量簡(jiǎn)易測(cè)試
Text3.Text = "串口已關(guān)"
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
Private Sub Command11_Click()
On Error GoTo errline
On Error GoTo errline
If Text1.Text < 0 Then
Text1.Text = 0
End If
Timer1.Enabled = True
errline:
If Err.Number = 13 Then
MsgBox ("輸入出錯(cuò)")
Text1.Text = 0
End If
Text1.Text = 0
End If
Timer1.Enabled = True
errline:
If Err.Number = 13 Then
MsgBox ("輸入出錯(cuò)")
Text1.Text = 0
End If
End Sub
Private Sub Command12_Click()
Text1.Text = 0
Timer1.Enabled = False
Text1.Text = 0
Timer1.Enabled = False
End Sub
Private Sub Command2_Click()
On Error GoTo errline:
On Error GoTo errline:
MSComm1.Output = "5"
Shape1.FillColor = vbRed
Exit Sub
Shape1.FillColor = vbRed
Exit Sub
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
Private Sub Command3_Click()
On Error GoTo errline:
MSComm1.Output = "2"
Shape2.FillColor = vbGreen
Exit Sub
Shape2.FillColor = vbGreen
Exit Sub
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
Private Sub Command4_Click()
On Error GoTo errline:
MSComm1.Output = "6"
Shape2.FillColor = vbRed
Exit Sub
Shape2.FillColor = vbRed
Exit Sub
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
Private Sub Command5_Click()
On Error GoTo errline:
MSComm1.Output = "3"
Shape3.FillColor = vbGreen
Exit Sub
Shape3.FillColor = vbGreen
Exit Sub
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
Private Sub Command6_Click()
On Error GoTo errline:
MSComm1.Output = "7"
Shape3.FillColor = vbRed
Exit Sub
Shape3.FillColor = vbRed
Exit Sub
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
Private Sub Command7_Click()
On Error GoTo errline:
MSComm1.Output = "4"
Shape4.FillColor = vbGreen
Exit Sub
Shape4.FillColor = vbGreen
Exit Sub
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
Private Sub Command8_Click()
On Error GoTo errline:
MSComm1.Output = "8"
Shape4.FillColor = vbRed
Exit Sub
Shape4.FillColor = vbRed
Exit Sub
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
Private Sub Command9_Click()
On Error GoTo errline:
MSComm1.CommPort = 6
MSComm1.Settings = "9600,n,8,1"
MSComm1.InputMode = comInputModeText
MSComm1.InputLen = 0
MSComm1.PortOpen = True
Timer2.Enabled = True
Timer3.Enabled = True
MSComm1.Settings = "9600,n,8,1"
MSComm1.InputMode = comInputModeText
MSComm1.InputLen = 0
MSComm1.PortOpen = True
Timer2.Enabled = True
Timer3.Enabled = True
Text3.Text = "串口已開"
Exit Sub
errline:
If Err.Number = 8013 Then
Text3.Text = "串口已開"
End If
Err.Clear
End Sub
Private Sub Form_Load()
End Sub
Private Sub Text1_Change()
On Error GoTo errline:
errline:
If Err.Number = 13 Then
Text1.Text = "輸入錯(cuò)誤"
End If
Err.Clear
On Error GoTo errline:
errline:
If Err.Number = 13 Then
Text1.Text = "輸入錯(cuò)誤"
End If
Err.Clear
End Sub
Private Sub Timer1_Timer()
On Error GoTo errline
If Text1.Text < 0 Then
Text1.Text = 0
End If
On Error GoTo errline
If Text1.Text < 0 Then
Text1.Text = 0
End If
If Text1.Text = 0 Then
MSComm1.Output = "5"
MSComm1.Output = "6"
MSComm1.Output = "7"
MSComm1.Output = "8"
Shape1.FillColor = vbRed
Shape2.FillColor = vbRed
Shape3.FillColor = vbRed
Shape4.FillColor = vbRed
Timer1.Enabled = False
Exit Sub
MSComm1.Output = "5"
MSComm1.Output = "6"
MSComm1.Output = "7"
MSComm1.Output = "8"
Shape1.FillColor = vbRed
Shape2.FillColor = vbRed
Shape3.FillColor = vbRed
Shape4.FillColor = vbRed
Timer1.Enabled = False
Exit Sub
End If
Text1.Text = Text1.Text - 1
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
Text1.Text = Text1.Text - 1
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
Private Sub Timer2_Timer()
On Error GoTo errline
On Error GoTo errline
If MSComm1.Input = "9" Then
Text2.Text = "有反饋"
End If
If MSComm1.Input = "a" Then
Text2.Text = "無反饋"
End If
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
Text2.Text = "有反饋"
End If
If MSComm1.Input = "a" Then
Text2.Text = "無反饋"
End If
errline:
If Err.Number = 8018 Then
Text3.Text = "串口已關(guān)"
End If
Err.Clear
End Sub
Private Sub Timer3_Timer()
If Shape4.FillColor = vbGreen And Text2.Text = "有反饋" Then
Text4.Text = "運(yùn)行"
End If
If Shape4.FillColor = vbGreen And Text2.Text = "無反饋" Then
Text4.Text = "故障"
End If
If Shape4.FillColor = vbRed And Text2.Text = "無反饋" Then
Text4.Text = "停止"
End If
If Shape4.FillColor = vbGreen And Text2.Text = "有反饋" Then
Text4.Text = "運(yùn)行"
End If
If Shape4.FillColor = vbGreen And Text2.Text = "無反饋" Then
Text4.Text = "故障"
End If
If Shape4.FillColor = vbRed And Text2.Text = "無反饋" Then
Text4.Text = "停止"
End If
End Sub
Private Sub Timer4_Timer()
Timer4.Enabled = False
Timer4.Enabled = False
End Sub
評(píng)論