Testing For Non-Null Strings

Some might test for Null by using

If sSomeString <> "" Then

or

If Len(sSomeString) = 0 Then

While these might work, it’s 50% faster to use

If IsNull(sSomeString) Then

Check out the other “Is” operators, IsDate, IsEmpty and IsNumeric. Use the correct operator for the job you have to do.

 

This tip is reprinted from the VB Tips & Tricks Volume 1 book.
Part of this tip was submitted by: Bobby Holstein


Discover more from dotNetTips.com

Subscribe to get the latest posts sent to your email.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.