]、。·ˉˇ¨〃々—~‖…’”〕〉》」』〗】∶!"'),.:;?]` 呵呵,不好意思,让大家久等了,我这段时间一直在外出差,没办法上网,而且没有时间吧模块给做出来,要不你们自己编吧,我把需要的编码格式告诉你们,好么?
不过你们要尊重我的成果哦,我原来一直想把它给商业化了的,可是因为工作太忙,而且没人帮我搞这个东西,所以后来也就算了,每次回到家都累得只想睡觉,所以干脆就直接不做了,希望大家在编程序时,别忘了我,我叫张剑锐,郑州人,我的mail地址:jerrych@guohao.com
MsgBox " 河南同方科技有限公司 " + Chr(13) + " 程序制作:张剑锐 Email:jerrych@126.com", vbOKOnly
下边就是核心程序:
MSComm.Output = "AT+CMGF=1" + Chr(13) + Chr(10)
MSComm.Output = "AT+CSMP=4,167,0,8" + Chr(13) + Chr(10)
'上边两行语句作为联机是初始化用的命令
Private Sub SMSend(TxtNumber As String, TxtMessage As String) 'txtNumber 是目的号码 txtMessage 是信息内容
Dim TxtMsg As String
Dim Arr, ArrA, ArrB As String
Dim InChar, InCharB, Wait As String
Dim i As Single
MSComm.InBufferCount = 0
For i = 1 To Len(TxtMessage)
Arr = Mid(TxtMessage, i, 1)
ArrA = Hex(AscB(MidB(Arr, 1, 1)))
ArrB = Hex(AscB(MidB(Arr, 2, 1)))
If Len(ArrB) = 1 Then If Val(ArrB) = 0 Then ArrB = "00"
If Len(ArrA) = 1 Then ArrA = "0" + ArrA
TxtMsg = TxtMsg + ArrB + ArrA
Next i
If MSComm.PortOpen Then MSComm.Output = "AT+CMGS=" + Chr(34) + TxtNumber + Chr(34) + Chr(13) '送出短信目的号码
MSComm.Output = TxtMsg + "005B5F2052519510005D" + Chr(26) '送出已编码后的短信内容
EndIf
Wait = Waiting(Chr(26), 1)
If ErrorCode Then
'初始化错
Status.SimpleText = "未准备好!" + "错误"
MFlag = False '标记发送失败
Else
Status.SimpleText = "发送成功!"
MSComm.RThreshold = 1 '控件收到数据时将触发OnComm事件
MFlag = True
End If
End Sub
Private Function Waiting(Strings As String, WaitTime As Single) As String
Dim EndTime As Single
Dim Buffer As String
'计算结束时间
EndTime = Timer + WaitTime
'初始化数据
ErrorCode = 0
Do
DoEvents '处理其它事件
If MSComm.InBufferCount Then
'接收数据
Buffer = Buffer + MSComm.Input
If InStr(1, Buffer, Strings) Then
'接收到等待的字符串
Exit Do
End If
End If
If Timer >= EndTime Or ErrorCode Then
'等待超时
ErrorCode = 1
Exit Do
End If
Loop
'返回接收的字符串
Waiting = Buffer
End Function
好了,我快饿死了,你们有什么不懂的地方在给我发mail吧,我要去吃饭了
出差回来连饭都没得吃,不行,我要去吃饭了,你们先看看吧。