2011-06-17 133 views
0

我有一個簡單的腳本,我不想在最後關閉(退出)。我希望它再次從頭開始。VB腳本簡單循環問題

Dim FJobName, objShell, FRevent, FReventNo, FPrevJobName 
FJobName=InputBox ("Job Name","Plates Complete","ACT") 
result=Msgbox(FJobName ,vbYesNo, "New Job?") 
If result = vbYes Then 
FRevent="raiseevent SetJobStatus_r3 " & FJobName & " InCart New -host 194.128.255.22 -port 61235" 
Set objShell = WScript.CreateObject ("WScript.shell") 
objShell.run FRevent 
Else 
If result = vbNo Then 
result=Msgbox(FJobName ,vbYesNo, "Repeat Job?") 
If result = vbYes Then 
FPrevJobName=InputBox ("Previous Job Name?","Plates Complete","") 
result=Msgbox(FPrevJobName ,vbYesNo, "Is this correct?") 
If result = vbYes Then 
FReventNo="raiseevent SetJobStatus_r3 " & FJobName & " InCart Repeat " & FPrevJobName & " -host 194.128.255.22 -port 61235" 
Set objShell = WScript.CreateObject ("WScript.shell") 
objShell.run FReventNo 
End If 
End If 
End If 
End If 
+1

我已經格式化你的代碼的代碼,下一次選擇該自己做,按鈕可以編輯窗口中的菜單欄上找到,並期待這樣的:'{}'爲了保證及時回答,您可能想花時間縮進。 – Fionnuala

回答

1

將代碼包裝在while循環中。您可以設置結束條件或提示用戶。沿着這些路線的東西:

While 1=1 
    ' *Your Code Here* 

    ' Prompt user to quit/continue 
    If msgbox("Continue?", vbYesNo) = vbNo Then 
     WScript.quit 
    End If 
    ' Alternately check criteria to quit/continue 
    if myQuitCriteria = True Then 
     WScript.quit 
    End If 
Wend 
+0

非常感謝dmogle,工作的魅力;) – user791276