Option Explicit Private Text1text As String Private RTUCRC As String '串口选择 Private Sub Combo1_Click() MSComm1.CommPort = Combo1.ListIndex + 1 End Sub '数据位改变 Private Sub Combo2_Click() Call setting End Sub '波特率改变 Private Sub Combo3_Click() Call setting End Sub '奇偶校验改变 Private Sub Combo4_Click() Call setting End Sub '停止位改变 Private Sub Combo5_Click() Call setting End Sub Private Sub setting() MSComm1.Settings = CStr(Combo3.Text) & "," & CStr(Combo4.Text) & "," & CStr(Combo2.Text) _ & "," & CStr(Combo5.Text) End Sub '打开关闭串口 Private Sub Command1_Click() On Error Resume Next If MSComm1.PortOpen = False Then MSComm1.PortOpen = True Else MSComm1.PortOpen = False End If
If MSComm1.PortOpen Then '打开关闭按钮显示文字及combo1使能 Command1.Caption = "关闭串口" Combo1.Enabled = False Else Command1.Caption = "打开串口" Combo1.Enabled = True End If
If Err Then '打开串口失败,则显示出错信息 MsgBox Error$, 48, "错误信息" &nb