PC机串口控制GSM模块收发短信系统设计(流程图+源程序) 第3页
'Mobcomm.InBufferCount = 0
Mobcomm.Output = "AT+CMGD=" + index.Text + Chr(13) + Chr(10)
Sleep (400)
'mobcomm.OutBufferCount = 0
'mobcomm.Output = "13138529082" + vbCr
If Mobcomm.InBufferCount > 0 Then
Instring = Mobcomm.Input
If InStr(Instring, "OK") Then
MsgBox "成功删除第" + index.Text + "条信息!", vbOKOnly, "提示"
Else
MsgBox "信息删除不成功!"
End If
End If
'rmsg.Text = Mid(Instring.Text, 1, InStr(Instring, Chr(13) + Chr(10)))
'rmsg.Text = Unicode2AscII(stringdeal(Instring))
'rmsg.Text = Mid(Instring, 11)
'Sleep (100)
'mobcomm.OutBufferCount = 0
'mobcomm.Output = Text1.Text + Chr(26)
Sleep (100)
'End If
'If InStr(Instring, "OK") Then
'End If
If Mobcomm.PortOpen = True Then
Mobcomm.PortOpen = False
End If
myActiveX.Active = True
'If Mobcomm.PortOpen = False Then
' Mobcomm.PortOpen = True
'End If
' Mobcomm.Output = "AT+CMGD=" & index.Text + vbCr
' Sleep (300)
' If Mobcomm.InBufferCount > 0 Then
' Mobcomm.InputLen = 0
' temp$ = Mobcomm.Input
' Mobcomm.InBufferCount = 0
' If InStr(buf, "OK") Then
' MsgBox "该信息已删除!"
' Else
' MsgBox "信息删除不成功!"
' End If
' End If
End Sub
Private Sub Form_Load()
Combo1(1).ListIndex = 0 '选择端口和波特率
Combo2(1).ListIndex = 4
myActiveX.Active = True '打开模块
End SubPrivate Sub msgsend_Click()
Dim MsgAdr As String
Dim TelNo As String
Dim Smsg As String
Dim PDU As String
Dim Leng As String
Dim Length As Integer
Dim AllLength As Integer
Length = 2 * Len(msg.Text)
Leng = Hex(Length)
If Len(Leng) = 1 Then
Leng = "0" & Leng
End If
AllLength = 15 + Length
MsgAdr = Trim(telc("8613800758500")) '肇庆动感地带短信信中心地址
TelNo = Trim(telc(teln.Text)) '手机号码
Smsg = Trim(AscII2Unicode(msg.Text)) '短信息内容
PDU = midx & TelNo & sufx & Leng & Smsg
'PDU = "0011000D91683167006059F100080108828265E55FEB4E50"
'AllLength = 23
myActiveX.Active = False
If Mobcomm.PortOpen = False Then
Mobcomm.PortOpen = True
SMSend AllLength, PDU '调用短信息发送程序
End If
If Mobcomm.PortOpen = True Then
Mobcomm.PortOpen = False
myActiveX.Active = True
End If
' myActiveX.SendTextSMS Trim(teln.Text), Trim(msg.Text)
'If Sendsms(Trim(teln.Text), Trim(msg.Text)) = True Then
'If Sendsms = True Then
' MsgBox "信息发送成功!"
'End If
End Sub
Private Function stringdeal(ByVal st As String)
stringdeal = Mid(st, InStr(st, Chr(10)) + 16)
End Function
Private Sub rm_Click() '阅读信息
Dim N As Integer
Dim Instring As String
www.751com.cn = 0
Mobcomm.InputLen = 0
Sleep (100)
Instring = ""
Mobcomm.Output = "AT+CMGF=0" + vbCr
Sleep (400)
If Mobcomm.InBufferCount > 0 Then
Instring = Mobcomm.Input
Mobcomm.InBufferCount = 0
Mobcomm.OutBufferCount = 0
If InStr(Instring, "OK") Then
Mobcomm.Output = "AT+CMGR=" + index.Text + Chr(13) + Chr(10)
End If
Instring = ""
End IfSleep (500)If Mobcomm.InBufferCount > 0 Then
Instring = Mobcomm.Input
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页