我目前正在爲我製作的一些vbs腳本製作一個簡單的UI(用戶界面)。我剛剛在一開始就添加了一個要求用戶名的部分。我的問題是每次使用這個「返回」選項轉到先前的「選項卡」時,它會重複詢問你的名字。我已經尋找了許多不同的方式來使它起作用,但我不能。我無法找到Loop/Exit的工作。我嘗試將名稱腳本分開,以便在開始時運行它,並在返回時轉到主腳本。但那意味着我不會在第二個腳本上知道他們的名字,因爲它沒有變量值。這是劇本!就像是去?
Dim Input
Dim Input1
Dim Input2
Dim Input3
Dim InputName
InputName = Inputbox("Please Enter Your Name", "Name")
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
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
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 Input2 = "Back" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
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 Wsh Shell = 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 Input3 = "Back" Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\Users\Owner\Desktop\Solus\Solus.vbs"
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
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
我如何使「返回」選項工作是通過重新運行該程序,以便它將從頭再次開始。通過在主腳本中添加「返回」,它將首先運行,並且每次返回時都會發生。我不能擁有。如果我決定將名稱分開,所以它不會運行,主腳本會丟失名稱變量,不能使用它,這將是無用的。如果我犯了一些錯誤,我很抱歉。 在此先感謝! BTH
此代碼可以真正使用一些空格,縮進和註釋。這是一個很難理解代碼的牆。 – JNevill
@JNevill,我已經照顧過縮進。它正在進行同行評審。 –
我注意到你正在爲每個If語句創建一個新的WScript.Shell對象。如果你每次都必須這樣做,它不是條件的一部分,所以你可以將它移到頂端。你只需要一個'Shell'對象來運行你的代碼。其次,如果您需要評估那麼多條件,請考慮'Select Case'。最後但並非最不重要的是,請對「Do..While ... Loop」進行一些研究,以照顧您的編碼。不幸的是,我現在無法給出實際答案,因爲我在這裏遇到了其他問題,但如果您以後沒有收到任何答覆,我會試一試。 –