Re: Checking for A Blank String



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/>

.



Relevant Pages

  • Re: Checking for A Blank String
    ... Herfried K. Wagner [MVP] wrote: ... contain an empty string: ... The code you posted would throw a 'NullReferenceException' in this case. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Component to design workflow
    ... Wagner R. Landgraf ... > I need similar features like the FREE Java component JGraph. ... > "Wagner R. Landgraf" wrote in message ... >> I would kindly ask you to check Diagram Studio at>> http://www.tmssoftware.com/diagram.htm, and specially the workflow demo. ...
    (borland.public.delphi.thirdpartytools.general)
  • Wagner / Paray Question
    ... features a purely orchestral version of 'Wotan's Farewell and Magic ... instruments. ... 'bleeding chunks' of Wagner have appeared on record with no indication ...
    (rec.music.classical.recordings)
  • Re: Upgrade Question
    ... Herfried K. Wagner [MVP] wrote: ... the designer in addition to the features currently provided? ... I don't think it was clumsy, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Who uses the My stuff - and why?
    ... dialogs. ... I disable 'My' features in class library projects because they ... M S Herfried K. Wagner ...
    (microsoft.public.dotnet.languages.vb)