我目前正在为我制作的某些vbs脚本制作一个简单的愚蠢UI(用户界面)。我刚刚添加了一个部分,它在开头询问用户的名字。我的问题是每次我使用这个"返回"选择转到上一个"标签"它重新询问你的名字。我已经找到了许多不同的方法来让它发挥作用,但我无法做到。我无法找到循环/退出工作的东西。我尝试将名称脚本分开,以便在开始时运行它,当你返回时它会转到主脚本。但这意味着我不会在第二个脚本上知道他们的名字,因为它不会有变量值。这是脚本!。
batch_size
我如何制作"返回"选项工作是通过重新运行程序,以便它再次从头开始。添加"返回"对于主脚本来说,它将是第一个运行的东西,每次你回去都会发生。这是我无法做到的。如果我决定将名称部分分开以便它不会被运行,那么主脚本将丢失名称变量并且无法使用它并且它将毫无用处。如果我犯了一些错误,我很抱歉。 提前致谢! BTH
答案 0 :(得分:1)
可以使用Goto
声明,但使用它通常被认为是不好的做法,因为它会将您的代码变成意大利面条。或者,循环在这里是一个很好的方法。收集名称后,您将继续循环,直到此人进入"退出"在外部对话框中:
Dim Input
Dim Input1
Dim Input2
Dim Input3
Dim InputName
InputName = Inputbox("Please Enter Your Name", "Name")
Do While Input <> "Quit"
Input = Inputbox("Weclome " & InputName & "" & vbNewLine & "Choose One Of The Options!" & vbNewLine & "" & vbNewLine & "Information" & vbNewLine & "Cool" & vbNewLine & "Hacks" & vbNewLine & "Quit", "Solus")
If Input = "Information" Then
Input1 = Inputbox("Here's The Information!" & vbNewLine & "" & vbNewLine & "Info" & vbNewLine & "Speech" & vbNewLine & "Back" & vbNewLine & "Quit", "Information")
If Input1 = "Info" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Information\Info.txt"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
ElseIf Input1 = "Speech" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Information\Speech.vbs"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
ElseIf Input1 = "Back" Then
'do nothing
ElseIf Input1 = "Quit" Then
Wscript.Quit
Else
msgbox("Please Enter One Of The Options Next Time!")
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
End If
ElseIf Input = "Cool" Then
Input2 = Inputbox("Here's Some Scripts!" & vbNewLine & "" & vbNewLine & "Abracadabra" & vbNewLine & "Calculator" & vbNewLine & "Matrix" & vbNewLine & "Back" & vbNewLine & "Quit", "Cool")
If Input2 = "Abracadabra" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Cool\Abracadabra.vbs"
ElseIf Input2 = "Calculator" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Cool\Calculator.vbs"
ElseIf Input2 = "Matrix" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Cool\Matrix.bat"
ElseIf Input1 = "Back" Then
'do nothing
ElseIf Input2 = "Quit" Then
Wscript.Quit
Else
msgbox("Please Enter One Of The Options Next Time!")
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
End If
ElseIf Input = "Hacks" Then
Input3 = Inputbox("Here's Some Hacks!" & vbNewLine & "" & vbNewLine & "Failure" & vbNewLine & "Haxs" & vbNewLine & "Rekt" & vbNewLine & "Spam" & vbNewLine & "TheOnly" & vbNewLine & "Back" & vbNewLine & "Quit", "Hacks")
If Input3 = "Failure" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Hacks\Failure.vbs"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
ElseIf Input3 = "Hacks" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Hacks\Haxs.vbs"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
ElseIf Input3 = "Rekt" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Hacks\Rekt.vbs"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
ElseIf Input1 = "Back" Then
'do nothing
ElseIf Input3 = "Spam" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Hacks\Spam.bat"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
ElseIf Input3 = "TheOnly" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
ElseIf Input3 = "Quit" Then
Wscript.Quit
Else
msgbox("Please Enter One Of The Options Next Time!")
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
End If
Elseif Input = "Quit" Then
'do nothing. While loop will exit
Else
msgbox("Please Enter One Of The Options Next Time!")
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
End If
Loop