请问,vb 调用shell外部程序后,程序怎样暂停等待外部程序处理完后,自建程序才继续执行

我的程序是这样子的
bat 生成个文件a,然后程序检测,提取其中的数据,接着再运行,a文件,在检测,提取·

num = 3
a1 = xlsheet.Cells(num, 1)
Do Until num = 7

Dim filename As String

filename = File1.Path & "\" & "screen.inp"

Open filename For Output As #1
Print #1, ………………
Close #1

Shell "x.bat"

Call aa(m1, dm1)
Call cc(c10, d10)
mysheet.Cells(num, 5) = d10
mysheet.Cells(num, 4) = c10

mysheet.Cells(num, 3) = dm1

mysheet.Cells(num, 2) = m1

num = num + 1

Loop
问题出现 主要是 shell "x.bat"文件 我算完了之后 ,所有结果都是最后一次运行的x.bat文件生成的数据

第1个回答  2009-06-16
On Error Resume Next
Dim Wsh As Object
Dim Re As Integer
Set Wsh = CreateObject("WScript.Shell")
Re = Wsh.run("cmd.exe", 1, True)

WshShell方法如下…………
WshShell.Run (strCommand, [intWindowStyle], [blnWaitOnReturn])
blnWaitOnReturn为布尔值,就是等待,加了这个就有返回码……
但是如果cmd.exe被强制关闭将溢出……
第2个回答  2009-06-16
调用API函数:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
并结合DoEvents

比如(等待0.1秒):
Sleep 100
DoEvents
第3个回答  2009-06-17
你又有问题了?下次有问题直接百度HI吧。本回答被提问者采纳
相似回答