Re: Checking for A Blank String



Herfried K. Wagner [MVP] wrote:
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.


Yes, ok, it's almost only a wrapper.

--
Göran Andersson
_____
http://www.guffa.com
.



Relevant Pages

  • Re: Checking for A Blank String
    ... Herfried K. Wagner [MVP] wrote: ... contain an empty string: ... For all the new features and functionality ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Auf eine Dll Funktion zugreifen?
    ... > in dieser Zeile erhalte ich eine NullReferenceException ... Herfried K. Wagner [MVP] ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: Checking for A Blank String
    ... contain an empty string: ... For all the new features and functionality offered in .NET, I'll still go for good ol' Lenevery time. ... The code you posted would throw a 'NullReferenceException' in this case. ... M S Herfried K. Wagner ...
    (microsoft.public.dotnet.languages.vb)
  • Re: mailto
    ... extended by Herfried K. Wagner [MVP]: ... Imports System.Diagnostics ... Public Sub StartDefaultMail(_ ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: Change to email functionality - reposted.
    ... extended by Herfried K. Wagner [MVP]: ... Imports System.Diagnostics ... Public Sub StartDefaultMail(_ ...
    (microsoft.public.dotnet.languages.vb)

Loading