PC机串口控制GSM模块收发短信系统设计(流程图+源程序) 第4页

PC机串口控制GSM模块收发短信系统设计(流程图+源程序) 第4页
SMSdeal Instring

Sleep (100)

   If InStr(Instring, "OK") Then
      MsgBox "成功读取第" + index.Text + "条信息!", vbOKOnly, "系统提示"
   Else
      MsgBox "该信息为空!", vbOKOnly, "系统提示"
   End If
   Instring = ""
End If

If Mobcomm.PortOpen = True Then
   Mobcomm.PortOpen = False
   myActiveX.Active = True
End If
End Sub
Private Function SMSdeal(SMS As String)

On Error Resume Next

 Dim SM As String
 Dim SN As String
 Dim STIME As String
 Dim SMG As String
 Dim SLONG, N As Integer
If InStr(SMS, "0891") Then
SM = Mid(SMS, InStr(SMS, "0891"))
SN = ConTelc(Mid(SM, 25, 14))
STIME = ConTimec(Mid(SM, 43, 14))
SLONG = CInt(Mid(SM, 57, 2))
N = SLONG * 4
SMG = Unicode2AscII(Mid(SM, 59, N))
    rmsg.Text = "  短信类型: " + "已读信息" + vbCr + vbLf + "  对方号码: " + SN + vbCr + vbLf + "  发送时间: " _
    + STIME + vbCr + vbLf + "  短信长度: " + Str(SLONG / 2) + "字节" + vbCr + vbLf + "  信息内容:" + SMG + vbCr + vbLf
ElseIf InStr(SMS, "018") Then
    SM = Mid(SMS, InStr(SMS, "018"))
    SLONG = CInt(Mid(SM, 17, 2))
    N = SLONG * 4
    SMG = Unicode2AscII(Mid(SM, 19, N))
    rmsg.Text = "  短信类型: " + "存储信息" + vbCr + vbLf + "  信息内容:" + SMG + vbCr + vbLf
End If
End Function
Private Sub rpb_Click()
 myActiveX.ReadPhoneBook "1", myActiveX.PhoneBookCount
End Sub

Private Sub Timer1_Timer()
Dim buf As String
If Mobcomm.InBufferCount > 0 Then
   Timer1.Enabled = False
   Mobcomm.InputLen = 0
   buf = Mobcomm.Input
   If InStr(buf, "OK") = 0 Then
   MsgBox "端口打开有误!" & tl
   End If
End If
End Sub
Private Sub Timer2_Timer()
 If Mobcomm.InBufferCount > 0 Then
    MsgBox "你有新的信息,请查收!"
    If IntChk$ = vbOK Then
    Mobcomm.InputLen = 0
    buf$ = Mobcomm.Input
    'Timer2.Enabled = False
    remsg$ = StrConv(buf, vbFromUnicode)
    DebugText remsg               '信息显示函数
    End If
 End If
End Sub
Private Sub DebugText(Str)    '设定输出格式
    rmsg.Text = rmsg.Text + Str + Chr(13) + Chr(10)    '输出消息
    SendMessage rmsg.hwnd, EM_LINESCROLL, 0, 1          '向下卷行
End Sub
Private Sub myActiveX_OnNewSMS(ByVal ReadState As String, ByVal sDateTime As String, ByVal sNum As String, ByVal sText As String, ByVal sSCA As String)
   
    '收到新消息
     DebugText "================= 收到新消息 ==================="
     DebugText "时间日期: " + sDateTime
     DebugText "电话号码: " + sNum
     DebugText "消息内容: " + sText
     DebugText "================================================"
   
     MsgBox "收到新消息:" + sNum  
     End Sub
Private Sub myActiveX_OnPhoneBookList(ByVal PhoneBook As String)
 phbook.Text = PhoneBook      '显示电话本内容
    End Sub
Private Sub Portopen_Test()     '打开端口并测试
' If Mobcomm.PortOpen = False Then
'    Mobcomm.CommPort = True
' End If
 Mobcomm.Output = "AT" + vbCr
 Timer1.Enabled = True
End Sub

上一页  [1] [2] [3] [4] [5] [6] [7] 下一页

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有