vba IsNothing 的反义词是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7757233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 14:16:00  来源:igfitidea点击:

what is the opposite of IsNothing?

vba

提问by giles

I want to say If the field "Resource" holds a value" ... thenbasically the opposite of

我想说的If the field "Resource" holds a value" ... then基本上是相反的

IIF(IsNothing(Fields!Resource.Value)

IIF(IsNothing(Fields!Resource.Value)

can you please help

你能帮忙吗

回答by Widor

Just add NOT:

只需添加NOT

If Not IsNothing(something) Then ...

EDIT :

编辑 :

Having just seen the vbatag,

刚刚看到vba标签,

Dim myVariable as Object    
If Not myVariable Is Nothing Then ...

回答by aevanko

A very efficient way to check a value exists is to check it's length:

检查值是否存在的一种非常有效的方法是检查它的长度:

If Len(Fields!Resource.Value) <> 0

如果 Len(Fields!Resource.Value) <> 0

回答by Patrick Honorez

IsNothing() does NOT exist in VBA. To check if a field or a variant contains something, you should use
If myField Is NUll then

IsNothing() 在 VBA 中不存在。要检查字段或变体是否包含某些内容,您应该使用
If myField Is NUll then

To check for unassigned objects, use

要检查未分配的对象,请使用

If myObject Is Nothing Then