存在的Null值/ Nothing /“"”或不 [英] The Presents of Null values/Nothing/"" or not

查看:103
本文介绍了存在的Null值/ Nothing /“"”或不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试检查空值的呈现或空值不存在
。我的示例代码如下:

如果EmailAddresses什么都没有那么


SendMailMessage(EmailAddresses,AlertTitle,

ViolationBody)

结束如果

以上代码在检查空礼物时是否有效

值/ Nothing /""。

但是,我想检查null是否存在,即


如果EmailAddresses不是什么,那么


SendMailMessage(EmailAddresses,AlertTitle,

ViolationBody)

结束如果


以上代码无法编译。


基本上我想知道什么时候出现空值而不存在。


谢谢


I''m trying to check for the presents of null values or null value not being
present. My sample code below:
If EmailAddresses Is Nothing Then

SendMailMessage(EmailAddresses, AlertTitle,
ViolationBody)
End If
The above code works when checking for the presents of a null
value/Nothing/"".
However, I want to check for null not being present ie.

If EmailAddresses not Nothing Then

SendMailMessage(EmailAddresses, AlertTitle,
ViolationBody)
End If

The above code will not compile.

Basically I want to know when nulls are present and not present.

Thanks


推荐答案

如果EmailAddresses不是Nothing那么


将以上内容更改为:


如果不是EmailAddresses什么都没有呢

SendMailMessage(EmailAddresses,AlertTit le,
ViolationBody)
结束如果
If EmailAddresses not Nothing Then
Change the above to:

If Not EmailAddresses Is Nothing Then

SendMailMessage(EmailAddresses, AlertTitle,
ViolationBody)
End If



Imran。


Imran.


我在下面尝试了你的例子结果是一样的。它执行

发送,当EmailAddresses的值为空值(字符串)或不为空时

值,这意味着它包含一个电子邮件地址。


我可以在这里遗漏一些东西。如果没有电子邮件地址,那么没有

需要发送邮件。


谢谢

" Imran Koradia"写道:
I tried your example below and the results are the same. It executes the
send when the value of EmailAddresses is a null value (string) or not null
value which means it contains an email address.

Could I be missing something here. If there is no email address then no
need to send mail.

Thanks
"Imran Koradia" wrote:
如果EmailAddresses不是Nothing那么
If EmailAddresses not Nothing Then



将上述内容改为:

如果不是电子邮件地址则没有那么



Change the above to:

If Not EmailAddresses Is Nothing Then


SendMailMessage(EmailAddresses,AlertTitle,
ViolationBody)
结束如果

SendMailMessage(EmailAddresses, AlertTitle,
ViolationBody)
End If



Imran。


Imran.



你没有提到EmailAddresses在你的第一篇文章中是一个字符串(或

可能我读了一半:))。我以为它是一个对象(这就是为什么你的b
$ b为什么都没有测试)。为了测试字符串是否为空("),

你应该使用它:


如果EmailAddresses.Length> 0然后

''它是一个非空字符串

SendMailMessage(EmailAddresses,AlertTitle,ViolationBody)

结束如果

希望有所帮助..

Imran。


" Larry Bird" <拉******* @ discussions.microsoft.com>在消息中写道

新闻:9A ********************************** @ microsof t.com ...
You didn''t mention EmailAddresses was a string in your first post (or
probably I half read it :)). I assumed it was an object (which is why you
were testing for nothing). To test whether a string is empty ("") or not,
you should use this:

If EmailAddresses.Length > 0 Then
'' Its a non-empty string
SendMailMessage(EmailAddresses, AlertTitle, ViolationBody)
End If
hope that helps..
Imran.

"Larry Bird" <La*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
我在下面尝试了你的例子,结果是一样的。当EmailAddresses的值为空值(字符串)或非空值时,它执行
发送值,这意味着它包含一个电子邮件地址。

我可以在这里遗漏一些东西吗? 。如果没有电子邮件地址,则无需发送邮件。

谢谢

" Imran Koradia"写道:
I tried your example below and the results are the same. It executes the
send when the value of EmailAddresses is a null value (string) or not null
value which means it contains an email address.

Could I be missing something here. If there is no email address then no
need to send mail.

Thanks
"Imran Koradia" wrote:
如果EmailAddresses不是Nothing那么
If EmailAddresses not Nothing Then



将上述内容改为:

如果不是电子邮件地址则没有那么



Change the above to:

If Not EmailAddresses Is Nothing Then


SendMailMessage(EmailAddresses,AlertTitle,
ViolationBody)
结束如果

SendMailMessage(EmailAddresses, AlertTitle,
ViolationBody)
End If



Imran。


Imran.



这篇关于存在的Null值/ Nothing /“&quot;”或不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆