取消数组输入框

Tom*_*cat 0 arrays vbscript inputbox

我试图使取消功能适用于我的数组它适用于一个简单的输入框但数组(InputBox(不喜欢它).

工作代码.

If strVarValue = vbNullString Then
    MsgBox ("User canceled!")
    WScript.Quit
End If
Run Code Online (Sandbox Code Playgroud)

我需要帮助的是什么

strIPAddress = Array(InputBox("IP address"))
If strIPAddress = vbNullString Then
    MsgBox ("User canceled!")
    WScript.Quit
End If
Run Code Online (Sandbox Code Playgroud)

不喜欢数组,因此为什么我的类型不匹配.

Ans*_*ers 5

仅在用户未按"取消"时才进行转换:

userInput = InputBox("IP address")
If userInput = "" Then
    MsgBox ("User canceled!")
    WScript.Quit
End If

strIPAddress = Array(userInput)
Run Code Online (Sandbox Code Playgroud)

此外,如果要区分"用户按下取消"和"用户按下确定而不输入值",则需要检查变量是否为Empty:

userInput = InputBox("IP address")
If IsEmpty(userInput) Then
    MsgBox ("User canceled!")
    WScript.Quit
ElseIf userInput = "" Then
    MsgBox ("Missing input!")
    WScript.Quit 1
End If

strIPAddress = Array(userInput)
Run Code Online (Sandbox Code Playgroud)