串口号不能改变
Private Sub Command2_Click()Text3.Text = ""Text1.SetFocusIf Combo1.ListIndex = 0 ThenMsgBox "请选择端口", vbInformation, "提示"ElseIf Combo1.ListIndex > 0 And Len(Text1.Text) <> 15 ThenText3.Text = "IMEI位数不对"Text3.BackColor = &HFF&ElseText3.BackColor = &H8000000FDim portset As String portset = Combo2.Text + ",n,8,1"On Error GoTo ER:Dim comm() As Stringcomm() = Split(Combo1.Text, "M")MSComm.CommPort = comm(1)MSComm.Settings = portsetMSComm.PortOpen = TrueText3.BackColor = &HFF00&Text3.Text = Combo1.Text + "初始化成功,连接手机中...!"[color=#FF0000]ER: Select Case Err.Number[/color] Case Is = 8002 Text3.Text = Text3.Text + "初始化失败:串口无效" Text3.BackColor = &HFF& Case Is = 8015 Text3.Text = Text3.Text + "初始化失败:波特率无效" Text3.BackColor = &HFF& Case Is = 380 Text3.Text = Text3.Text + "初始化失败:波特率无效" Text3.BackColor = &HFF& End Select On Error Resume Next MSComm.Output = "AT+ESLP=0" + Chr(13) Sleep 100 MSComm.Output = "AT+ESLP=0" + Chr(13) Sleep 100 MSComm.OutBufferCount = 0 MSComm.Output = "AT+ESLP=0" + Chr(13) Sleep 100 MSComm.OutBufferCount = 0 MSComm.Output = "AT+ESLP=0" + Chr(13) Sleep 100 info = MSComm.Input compa = info Like "*OK*" If compa = True Then Text3.Text = Combo1.Text + "与手机连接成功" Text3.Refresh Call Write_IMEI