美文网首页
Input Box返回值

Input Box返回值

作者: zhishou | 来源:发表于2016-05-31 14:11 被阅读0次

引用:How to Detect vba InputBox "Cancel" or "X" clicked other than detecting null input ?

You need to understand the built-in function. If you cancel the input, it will return a Zero length string. The Cancel button return an empty string. There is no Args for the Cancel button. So you cannot detect the Cancel button being press by the user.

  • “取消”或“X”测试是否为Null
    Sub test() On Error Resume Next Dim rng As Object rng = Application.InputBox("Select Range:", , , , , , , 8) Dim b As Boolean b=isNull(rng) MsgBox "Is Null ---" & b End Sub

不是Null

  • “取消”或“X”测试是否为Nothing
    Sub test() On Error Resume Next Dim rng As Object rng = Application.InputBox("Select Range:", , , , , , , 8) Dim b As Boolean If rng Is Nothing Then b = True Else b = False End If MsgBox "Is nothing ---" & b End Sub

是Nothing

  • 什么是Null,什么是Nothing
    要判断Nothing的,必须是一个对象(Object),未初始化的对象是Nothing
    Null 必须是一个变量。尚未完全理解。。。

引用:Nothing? Empty? Missing? Null?

相关文章

网友评论

      本文标题:Input Box返回值

      本文链接:https://www.haomeiwen.com/subject/qitcdttx.html