取消数组输入框 [英] cancel array Input Box
本文介绍了取消数组输入框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使cancel函数对我的数组起作用,它对简单的输入框起作用,但是Array(InputBox(不太喜欢它.
I am trying to make the cancel function work for my array it works for a simple input box but Array(InputBox( does not like it very much.
工作代码.
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,因此为什么我遇到类型不匹配的情况.
Doesn't like the Array hence why I'm getting type mismatch.
推荐答案
仅当用户未按取消"时才进行转换:
Do the conversion only if the user did not press "Cancel":
userInput = InputBox("IP address")
If userInput = "" Then
MsgBox ("User canceled!")
WScript.Quit
End If
strIPAddress = Array(userInput)
此外,如果要区分用户按下取消"和用户按下OK而不输入值",则需要检查变量是否为Empty
:
Also, if you want to distinguish between "user pressed Cancel" and "user pressed OK without entering a value" you need to check if the variable is 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)
这篇关于取消数组输入框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文