扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:hitbird 来源:天极网blog 2007年10月14日
关键字: Visual Basic 手机短信 收发程序
Public Function chg(rmsg As String) As String Dim tep As String Dim temp As String Dim i As Integer Dim b As Integer tep = rmsg i = Len(tep) b = i / 4 If i = b * 4 Then b = b - 1 tep = Left(tep, b * 4) Else tep = Left(tep, b * 4) End If chg = "" For i = 1 To b temp = "&H" & Mid(tep, (i - 1) * 4 + 1, 4) chg = chg & ChrW(CInt(Val(temp))) Next i End Function |
Public Function telc(num As String) As String Dim tl As Integer Dim ltem, rtem, ttem As String Dim ti As Integer ttem = "" tl = Len(num) If tl <> 11 And tl <> 13 Then MsgBox "wrong number." & tl Exit Function End If If tl = 11 Then tl = tl + 2 num = "86" & num End If For ti = 1 To tl Step 2 ltem = Mid(num, ti, 1) rtem = Mid(num, ti + 1, 1) If ti = tl Then rtem = "F" ttem = ttem & rtem & ltem Next ti telc = ttem End Function |
Const prex = "0891" Const midx = "11000D91" Const sufx = "000800" Public Function Sendsms(csca As String, num As String, msg As String) As _Boolean 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 psmsc = Trim(telc(csca)) pnum = Trim(telc(num)) pmsg = Trim(ascg(msg)) pdu = prex & psmsc & midx & pnum & sufx & leng & pmsg sleep(1) mobcomm.Output = "AT+CMGF=0" + vbCr mobcomm.Output = "AT+CMGS=" & Str(15 + length) + vbCr mobcomm.Output = pdu & Chr$(26) sleep(1) Sendsms = True End Function |
Public Function ascg(smsg As String) As String Dim si, sb As Integer Dim stmp As Integer Dim stemp As String sb = Len(smsg) ascg = "" For si = 1 To sb stmp = AscW(Mid(smsg, si, 1)) If Abs(stmp) < 127 Then stemp = "00" & Hex(stmp) Else stemp = Hex(stmp) End If ascg = ascg & stemp Next si ascg = Trim(ascg) End Function |
Public Sub readsms(rnum As String) mobcomm.Output = "AT+CMGF=1" + vbCr mobcomm.Output = "AT+CMGR=" & rnum + vbCr End Sub |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者