|
公司在access里写了点程序用来调用外部程序群发工资短信,设定发送每条短信等待10秒是足够的,但偶尔会出现发送响应慢,超过10秒的情况,这时AppActivate "G3 eWalk"语句会执行错误,从而程序终止执行。现在我希望将标红语句处加条判断,如果AppActivate "G3 eWalk"执行错误,则再等待30秒,这个if语句如何写,望高人帮助!!
程序代码如下:
Private Sub btnSMSSendSalaryTWS_Click()
Dim MyDB As Database, MyQuery As QueryDef, MyData As Recordset
Dim StartTime, EndTime
Const MB_OK = 0, MB_OKCANCEL = 1 ' Define buttons.
Const MB_YESNOCANCEL = 3, MB_YESNO = 4
Const MB_ICONSTOP = 16, MB_ICONQUESTION = 32 ' Define icons.
Const MB_ICONEXCLAMATION = 48, MB_ICONINFORMATION = 64
Const MB_DEFBUTTON2 = 256, IDYES = 6, IDNo = 7 ' Define other.
Set MyDB = CurrentDb()
Set MyData = MyDB.OpenRecordset("HRA_TWS_SMS_Base_SendThisTime", DB_OPEN_SNAPSHOT)
MyData.MoveFirst
Title = "MsgBox"
msg = "This operation will send SMS salary bill to each mobile phone user by Wireless Manager - Status."
msg = msg & " Do you want to continue?"
DgDef = MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON2 ' Describe dialog box.
RESPONSE = MsgBox(msg, DgDef, Title) ' Get user response.
If RESPONSE = IDYES Then ' Evaluate response
msg = "Please open Wireless Manager - Status, and turn on radio."
msg = msg & "Then press OK button."
RESPONSE = MsgBox(msg)
Do Until MyData.EOF
AppActivate "G3 eWalk"
SendKeys "^n", True
SendKeys MyData![MPhoneNo], True
SendKeys "{Tab}", True
SendKeys MyData![SalaryDetail], True
SendKeys "%s", True
SendKeys "{Enter}", True
MyData.MoveNext
StartTime = Timer
EndTime = Timer
Do While EndTime - StartTime <= 10
EndTime = Timer
Loop
Loop
MyData.Close
End If
AppActivate "Microsoft Access"
MsgBox "Send successfully!"
End Sub
|
|