本人以前寫過VB控制GSMmoden發送短信,只是接收的是普通手機,現在想發送短信到農行網端106575595599上去,卻顯示發送失敗。我檢查了一下,估計是接收方設定那里出了問題,原始碼如下:
Public Function SendsmsMobile(csca As String, num As String, MSG As String, msCommX As MSComm) As Boolean
'---------------------------------------------------發送短信
On Error GoTo errlb
Dim midx As String
Const prex = "0891"
midx = "0D91"'----------此處為普通11位手機
midx="001100"&midx
Const sufx = "000800"
Dim pdu, psmsc, pnum, pmsg As String
Dim leng As String
Dim length As Integer
length = Len(MSG)
length = 2 * length
leng = Hex(length)
If length < 16 Then
leng = "0" & leng
End If
psmsc = Trim(Telc(csca))
pnum = Trim(Telc(num))
pmsg = Trim(ascg(MSG))
pdu = midx & pnum & sufx & leng & pmsg
Delay 1
Dim stt 'As String
If msCommX.PortOpen = False Then
msCommX.PortOpen = True
End If
msCommX.Output = "AT+CMGF=0" + vbCr
msCommX.Output = "AT+CMGS=" & Str(15 + length) + vbCr
stt = msCommX.Input
msCommX.Output = pdu & Chr$(26)
For i = 1 To intSD
Delay 1
Next
'----停止5秒
stt = msCommX.Input
If InStr(stt, "ERROR") <> 0 Then
SendsmsMobile = False
GoTo 100
End If
If InStr(stt, "OK") <> 0 Then
SendsmsMobile = True
Else
SendsmsMobile = False
End If
100:
Exit Function
errlb:
MsgBox Err.Description, vbCritical
SendsmsMobile = False
End Function
具體如何改,請教各位大大
uj5u.com熱心網友回復:
自已頂起來!!轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/95303.html
上一篇:matlab新手求找錯誤
