Re: Checking for A Blank String
- From: "Herfried K. Wagner [MVP]" <hirf-spam-me-here@xxxxxx>
- Date: Sat, 10 Mar 2007 01:29:42 +0100
Göran,
"Göran Andersson" <guffa@xxxxxxxxx> schrieb:
If you want to check if your variable is not 'Nothing' and does not
contain an empty string:
\\\
If Len(s) > 0 Then
...
End If
///
This is my recommended way too. For all the new features and functionality offered in .NET, I'll still go for good ol' Len() every time.
The Len function is just a wrapper for the String.Length method.
If s.Length > 0 Then
...
End If
No, it's more than that. It will return 0 if the value passed to it is 'Nothing'. The code you posted would throw a 'NullReferenceException' in this case.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
.
- Follow-Ups:
- Re: Checking for A Blank String
- From: Göran Andersson
- Re: Checking for A Blank String
- References:
- Re: Checking for A Blank String
- From: Herfried K. Wagner [MVP]
- Re: Checking for A Blank String
- From: \(O\)enone
- Re: Checking for A Blank String
- From: Göran Andersson
- Re: Checking for A Blank String
- Prev by Date: RE: Compile error help
- Next by Date: Re: VB2005 & Smartphone development
- Previous by thread: Re: Checking for A Blank String
- Next by thread: Re: Checking for A Blank String
- Index(es):
Relevant Pages
|