2017-10-17 26 views
0

如果未输入密码,我将如何结束vbs文件,如果单击“好”,它将继续。 如果没有输入任何内容,我希望它结束​​。 是可能的吗?如何在没有给出条目的情况下结束vbs文件

If InputBox("Please enter the passcode.", "Restricted access") = "Passcode" Then MsgBox "Correct passcode. You may continue. 

Dim speaks, speech 
    name=inputbox("What's your name?", "WELCOME") 
    speaks=("Welcome ") + name 
    Set speech=CreateObject("sapi.spvoice") 
    speech.Speak speaks 
+2

请参阅'https://stackoverflow.com/a/20539978/6038551'。我假设你知道'WScript.Quit'。 –

回答

-1

你的意思是这样的吗?

Dim strPassword As String 
    strPassword = InputBox("Please enter the passcode.", "Restricted access") & "" 
If strPassword = "Passcode" then 
    MsgBox "Correct passcode. You may continue." 
    Dim speaks, speech 
    name=inputbox("What's your name?", "WELCOME") 
    speaks=("Welcome ") + name 
    Set speech=CreateObject("sapi.spvoice") 
    speech.Speak speaks 
else 
    WScript.Quit 
endif 
+2

'Dim strPassword As String'不是VBScript;问题是如何检查空输入/取消。 –

相关问题