Input Box返回值

引用: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?

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,562评论 5 6
  • Correctness AdapterViewChildren Summary: AdapterViews can...
    MarcusMa阅读 8,928评论 0 6
  • 一 起飞了,飞机徐徐而起。 看,我们飞起来了,腾着云,驾着雾,穿行于万里云端。 白云,或静或...
    雪儿1阅读 259评论 0 3
  • 一天难得有时间静下心来写作业,本来想把写作的时间放在中午,无奈我们这些北方人中午还要午休,下午还有一堆下午的事情,...
    秋门阅读 315评论 0 0
  • 猴王,印证了特劳特《定位》里对心智模型的解释。六小龄童的版本占据了人们心智中对猴王的第一认知,长久持续的在脑海中投...
    EnjoyThink阅读 267评论 0 0