首先,我很抱歉我是VBS的新手,但我正在尝试创建一个小脚本,它将完成一系列的击键,然后在一个网站上工作,然后转到另一个网站,完成另一系列的击键。
当在第一个网站上时,我需要问一个问题,比如这个动作完成了吗?是或否。
如果为No,则脚本需要返回到脚本的开头。如果是,则脚本需要继续。
稍后,在第二个网站上,在几次击键之后,我需要问另一个问题天气,以循环整个过程或停止。
我在谷歌上搜索了一些消息框解决方案,但似乎不起作用。我有过
第一个问题框。
intSerialNumber = _
Msgbox("Was there a problem?", _
vbYesNo, "Problem?")
If intSerialNumber = vbYes Then
LoopShip
Else
Continue
End If
Continue第二个问题框。
If msgbox("Continue?", vbYesNo) = vbNo Then
WScript.quit
End If
if LoopShip = True Then
LoopShip
End If
Wend发布于 2015-11-18 06:06:11
尝试将嵌套循环与函数一起使用,以提高可读性,如下所示。用户可以多次重新运行来自第一个网站的代码,并且可以多次重新运行来自两个网站的代码。
Dim problemsOccurred
problemsOccurred = vbYes
Do
Call firstWebsite()
problemsOccurred = secondWebsite()
Loop Until (problemsOccurred = vbNo)
Sub firstWebsite()
Dim firstWebsiteProblem
firstWebsiteProblem = vbYes
Do
'First Website code Goes here
firstWebsiteProblem = Msgbox("Was there a problem?", vbYesNo, "Problem?")
Loop Until (firstWebsiteProblem = vbNo)
End Sub
Function secondWebsite()
'Second WebSite code goes here
secondWebsite = MsgBox("Continue Whole Process?", vbYesNo)
End Functionhttps://stackoverflow.com/questions/33167365
复制相似问题