473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

The Presents of Null values/Nothing/"" or not

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


Nov 21 '05 #1
10 3054
If EmailAddresses not Nothing Then
Change the above to:

If Not EmailAddresses Is Nothing Then

SendMailMessage(EmailAddresses, AlertTitle,
ViolationBody)
End If

Imran.
Nov 21 '05 #2
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:
If EmailAddresses not Nothing Then


Change the above to:

If Not EmailAddresses Is Nothing Then

SendMailMessage(EmailAddresses, AlertTitle,
ViolationBody)
End If

Imran.

Nov 21 '05 #3
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...
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:
If EmailAddresses not Nothing Then


Change the above to:

If Not EmailAddresses Is Nothing Then

SendMailMessage(EmailAddresses, AlertTitle,
ViolationBody)
End If

Imran.

Nov 21 '05 #4
> However, I want to check for null not being present ie.

If EmailAddresses not Nothing Then
Use:

If Not EmailAddresses Is Nothing Then

"Larry Bird" <La*******@discussions.microsoft.com> wrote in message
news:43**********************************@microsof t.com... 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

Nov 21 '05 #5
Or,

If EmailAddresses <> "" Then
send mail
Else
don't send mail
End If
"Imran Koradia" <no****@microsoft.com> wrote in message
news:ei*************@TK2MSFTNGP14.phx.gbl...
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...
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:
>
> > If EmailAddresses not Nothing Then
>
> Change the above to:
>
> If Not EmailAddresses Is Nothing Then
>
> >
> > SendMailMessage(EmailAddresses, AlertTitle,
> > ViolationBody)
> > End If
> >
>
>
> Imran.
>
>
>


Nov 21 '05 #6
"Larry Bird" <La*******@discussions.microsoft.com> schrieb:
Basically I want to know when nulls are present and not present.


Depends on how you define 'null' for strings...

\\\
If _
Not EmailAddresses Is Nothing AndAlso _
EmailAddresses.Length > 0 _
Then
...
End If
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #7
What you've got is overkill and not needed to check a string for null, just
check for "".
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
"Larry Bird" <La*******@discussions.microsoft.com> schrieb:
Basically I want to know when nulls are present and not present.


Depends on how you define 'null' for strings...

\\\
If _
Not EmailAddresses Is Nothing AndAlso _
EmailAddresses.Length > 0 _
Then
...
End If
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #8
Larry,

Because everybody does something than me as well

Dim EmailAddress as string is
EmailAdress Is Nothing

Dim EmailAddress as string = "" is
EmailAdress.lenght = 0

Both work with
If EmailAdress = Nothing

I hope this helps?

Cor
Nov 21 '05 #9
"Scott M." <s-***@nospam.nospam> schrieb:
What you've got is overkill and not needed to check a string for
null, just check for "".


ACK, you could compare with "".

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #10
That worked great thank for the help
"Imran Koradia" wrote:
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...
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:

> If EmailAddresses not Nothing Then

Change the above to:

If Not EmailAddresses Is Nothing Then

>
> SendMailMessage(EmailAddresses, AlertTitle,
> ViolationBody)
> End If
>
Imran.


Nov 21 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Pablo J Royo | last post by:
Hello: i have a function that reads a file as an argument and returns a reference to an object that contains some information obtained from the file: FData &ReadFile(string FilePath); But ,...
13
by: Don Vaillancourt | last post by:
What's going on with Javascript. At the beginning there was the "undefined" value which represented an object which really didn't exist then came the null keyword. But yesterday I stumbled...
10
by: dcrespo | last post by:
Hi all, How can I replace all None values with the string 'Null' in a dictionary? For example: convert this: a = {'item1': 45, 'item2': None} into this:
13
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL"...
5
by: rengeek33 | last post by:
I am building a SQL statement for Oracle and need one part of it to read: , myvar = null, myvar2 = "1", myvar3 = "0", myvar4 = null, etc. I am constructing this string using the String...
5
by: Stewart | last post by:
Hi there, I would like to calculate a person's age in years (between 2 dates). I am using the following function for this calculation (source: http://www.mvps.org/access/datetime/date0001.htm)...
0
by: Paul | last post by:
Hi All. We have a custom class which we serialize. This class is regularly updated, and the old requests do not have a problem opening, apart from a couple!!! When it try's to deserialize the...
2
by: Stephen Plotnick | last post by:
I'm getting a bottom line with Null values andit causes a problem; how do I get rid of it?
5
RMWChaos
by: RMWChaos | last post by:
I am working on a script to create and remove DOM elements, and I want to make it as efficient as possible (no redundancies). Because DOM elements each have their own set of attributes, the function...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.