我正在使用它在 VB6 中使用 mCore ActiveX 组件发送短信。这段代码运行良好,但有时它会多次发送一条短信(事实上,在我关闭应用程序之前已经发送了数百次)。请指导我,因为我对 VB6 非常熟悉
Public Function SendSMS()
On Error Resume Next
Dim strSendResult As String
Dim ij As Integer
Dim message As String
Dim blnAllMsgsSent As Boolean
Dim message1
Dim id As Integer
blnAllMsgsSent = True
If objSMS.Connect Then
Timer2.Enabled = False
ij = 0
Sql = "SELECT id,message,MobileNo FROM tblSendSMS where status='Pending' order by id asc;"
RS.Open Sql, Conn, adOpenDynamic
If Not RS.EOF Then
RS.MoveFirst
Do While Not RS.EOF
message = RS!message
If RS!message <> "" Then
id = RS!id
'' send message now
strSendResult = objSMS.SendSMS(MobileNo, message)
strSendResult = ""
If objSMS.IsError(True, "Application.exe") Then
blnAllMsgsSent = False
End If
End If
If blnAllMsgsSent Then
Sql = "update tblSendSMS set status='Sent' where id=" & id
Conn.Execute Sql
End If
ij = ij + 1
RS.MoveNext
Loop
End If
RS.Close
Else
SetCommParameters
End If
Timer2.Enabled = True
End Function