【问题标题】:cancel array Input Box取消数组输入框
【发布时间】:2016-05-21 14:10:11
【问题描述】:

我正在尝试使取消功能适用于我的数组,它适用于简单的输入框,但 Array(InputBox( 不太喜欢它。

工作代码。

If strVarValue = vbNullString Then
    MsgBox ("User canceled!")
    WScript.Quit
End If

我需要什么帮助

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

不喜欢数组,因此我得到类型不匹配。

【问题讨论】:

  • 出于好奇:Array(InputBox("IP address")) 应该实现什么?你只会得到一个包含单个字符串元素的数组。
  • 这是一个很好的问题,你刚刚帮我解决了我的问题,数组用于传递值,而不是输入,所以是的,我发现了问题。谢谢:)

标签: arrays vbscript inputbox


【解决方案1】:

仅当用户未按“取消”时才进行转换:

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

strIPAddress = Array(userInput)

另外,如果你想区分“用户按下取消”和“用户按下确定而不输入值”,你需要检查变量是否为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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-29
    • 1970-01-01
    • 1970-01-01
    • 2019-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多