VB中调用mscomm控件发短信
'发送短信函数
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
' MsgBox pdu
MSComm1.Output = "AT+CMGF=0" + vbCr
MSComm1.Output = "AT+CMGS=" & str(15 + length) + vbCr
MSComm1.Output = pdu & Chr$(26)
Sleep (1000)
Text4.Text = MSComm1.Input
Sendsms = True
Open App.Path & "\readme.txt" For Output As #1
Print #1, pdu
Print #1, str(15 + length)
Close #1
End Function
这个发送函数执行后,没有发出短信
[解决办法]
程序没有问题,是硬件的问题。