主题:这段程序不能按顺序执行,怎么办
Sub process_stock()
Kill ("c:\mytext.txt")
Dim RetVal
RetVal = Shell("c:\\getdata.exe", 1)
While IsRunning(RetVal)
DoEvents
Wend
Dim RetVal1
RetVal1 = Shell("c:\\uptomdb.exe", 1)
While IsRunning(RetVal1)
DoEvents
Wend
Dim RetVal2
RetVal2 = Shell("c:\\readado.exe", 1)
While IsRunning(RetVal2)
DoEvents
Wend
RetVal3 = Shell("c:\\sendmsg.exe", 1)
While IsRunning(RetVal3)
DoEvents
Wend
Application.OnTime Now + TimeValue("00:30:00"), "process_stock"
End Sub
Function IsRunning(ByVal ProgramID) As Boolean
Dim hProgram As Long
hProgram = OpenProcess(0, False, ProgramID)
If Not hProgram = 0 Then
IsRunning = True
Else
IsRunning = False
End If
CloseHandle hProgram
End Function
Kill ("c:\mytext.txt")
Dim RetVal
RetVal = Shell("c:\\getdata.exe", 1)
While IsRunning(RetVal)
DoEvents
Wend
Dim RetVal1
RetVal1 = Shell("c:\\uptomdb.exe", 1)
While IsRunning(RetVal1)
DoEvents
Wend
Dim RetVal2
RetVal2 = Shell("c:\\readado.exe", 1)
While IsRunning(RetVal2)
DoEvents
Wend
RetVal3 = Shell("c:\\sendmsg.exe", 1)
While IsRunning(RetVal3)
DoEvents
Wend
Application.OnTime Now + TimeValue("00:30:00"), "process_stock"
End Sub
Function IsRunning(ByVal ProgramID) As Boolean
Dim hProgram As Long
hProgram = OpenProcess(0, False, ProgramID)
If Not hProgram = 0 Then
IsRunning = True
Else
IsRunning = False
End If
CloseHandle hProgram
End Function