To read the article online, visit http://www.4GuysFromRolla.com/webtech/tips/t040600-1.shtml

User Tips: Eliminating IsEmpty and IsNull Issues


By Gary Van Sluis

When dealing with COM or unfamiliar database schemas or regular code, sometimes you will find yourselves wondering whether to test if a variable is Null by using either:

  • IsEmpty(varname)
  • IsNull(varName)
  • If varname = 0
  • If varname <> 0, or
  • If varname > 0

This little quick trick will eliminate all of those issues and allow you to quickly move on to more pressing issues. Simply convert the variable to a string and check the length. Here is a quick sample.

If Len(varname & "") < 1

or you can use:

If Len(varname & "") = 0

or you can also do:

If Len(varname & "") <> 0

Either way, if its equal to 0 then it was empty or null but you elimate type mismatch errors that can cause delays in development.

Happy Programming!

Return to user tips...


Article Information
Article Title: User Tips: Eliminating IsEmpty and IsNull Issues
Article Author: Gary Van Sluis
Article URL: http://www.4GuysFromRolla.com/webtech/tips/t040600-1.shtml


Copyright 2017 QuinStreet Inc. All Rights Reserved.
Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers