Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Check if variable is empty

Reply
Thread Tools

Check if variable is empty

 
 
Shapper
Guest
Posts: n/a
 
      05-16-2005
Hello,

I am using this code line to check i a variable exists:
If cookie Is Nothing Then
....

How can I check if cookie is empty when cookie exists?

Thanks,
Miguel



 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      05-16-2005
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in news:OH0
#(E-Mail Removed):

> Hello,
>
> I am using this code line to check i a variable exists:
> If cookie Is Nothing Then
> ...
>
> How can I check if cookie is empty when cookie exists?



You can try:

Trim(Cookie) <> ""




--
Lucas Tam ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
 
 
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      05-16-2005
You could check the data inside the cookie.

if cookie.Values.Length == 0 then
'the cookie is empty
endif

HTH,

bill

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:OH0%(E-Mail Removed)...
> Hello,
>
> I am using this code line to check i a variable exists:
> If cookie Is Nothing Then
> ...
>
> How can I check if cookie is empty when cookie exists?
>
> Thanks,
> Miguel
>
>
>



 
Reply With Quote
 
=?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBNVlA=?=
Guest
Posts: n/a
 
      05-16-2005
If(Cookie.Values.Length == 0) Then
'cookie is empty
Else
'cookie is not empty
End If


---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Shapper" wrote:

> Hello,
>
> I am using this code line to check i a variable exists:
> If cookie Is Nothing Then
> ....
>
> How can I check if cookie is empty when cookie exists?
>
> Thanks,
> Miguel
>
>
>
>

 
Reply With Quote
 
Shapper
Guest
Posts: n/a
 
      05-16-2005
Hello,

My mistake: I gave the cookie example.

Basically I am looking to a way to check is a String is Empty or Null.

I know ASP.Net will have a IsEmptyOrNull Function.

I have been reading information about this in Asp.Net 1.1 but it seems
there are several ways to do it in relation to optimization.

I am in this moment using the following in VB.NET:

If myString Is Nothing Or myString = String.Empty Then
....

What do you think?

Cheers,
Miguel


"Cowboy (Gregory A. Beamer) - MVP" <(E-Mail Removed)>
wrote in message news:(E-Mail Removed):

> If(Cookie.Values.Length == 0) Then
> 'cookie is empty
> Else
> 'cookie is not empty
> End If
>
>
> ---
>
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
> "Shapper" wrote:
>
>
> > Hello,
> >
> > I am using this code line to check i a variable exists:
> > If cookie Is Nothing Then
> > ....
> >
> > How can I check if cookie is empty when cookie exists?
> >
> > Thanks,
> > Miguel
> >
> >
> >
> >


 
Reply With Quote
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      05-17-2005
I always check the length property of a string.

In c# code code I use is

string s;
if ( s == null || s.Length == 0 )
{

}

Length is a property of the string that returns much faster than comparing
to String.Empty.

bill


"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:O%(E-Mail Removed)...
> Hello,
>
> My mistake: I gave the cookie example.
>
> Basically I am looking to a way to check is a String is Empty or Null.
>
> I know ASP.Net will have a IsEmptyOrNull Function.
>
> I have been reading information about this in Asp.Net 1.1 but it seems
> there are several ways to do it in relation to optimization.
>
> I am in this moment using the following in VB.NET:
>
> If myString Is Nothing Or myString = String.Empty Then
> ...
>
> What do you think?
>
> Cheers,
> Miguel
>
>
> "Cowboy (Gregory A. Beamer) - MVP" <(E-Mail Removed)>
> wrote in message news:(E-Mail Removed):
>
> > If(Cookie.Values.Length == 0) Then
> > 'cookie is empty
> > Else
> > 'cookie is not empty
> > End If
> >
> >
> > ---
> >
> > Gregory A. Beamer
> > MVP; MCP: +I, SE, SD, DBA
> >
> > ***************************
> > Think Outside the Box!
> > ***************************
> >
> > "Shapper" wrote:
> >
> >
> > > Hello,
> > >
> > > I am using this code line to check i a variable exists:
> > > If cookie Is Nothing Then
> > > ....
> > >
> > > How can I check if cookie is empty when cookie exists?
> > >
> > > Thanks,
> > > Miguel
> > >
> > >
> > >
> > >

>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Altova Mapforce - xml 2 xml map: empty elements output although input element is not empty Lukas XML 3 11-10-2005 02:25 PM
Check empty variable. Strange problem. Need Help. Shapper ASP .Net 1 05-09-2005 11:42 PM
empty lists vs empty generators Brian Roberts Python 12 05-04-2005 08:59 PM
Check if a directory is empty and empty it Marcia Hon C Programming 8 02-14-2004 03:53 AM
empty/non-empty element John XML 1 07-16-2003 10:23 AM



Advertisments