When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
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...


ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article