IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
ASP Classic
Search ASP Classic Group:

Advanced
-Collapse +Expand ASP Classic Store

Prestwood eMagazine

June Edition
Subscribe now! It's Free!
Enter your email:

   ► KBWebsite Scri...ASP Classic   Print This     
Next Random Article Next Random Tidbit || Change Topic Random From All

Random Tidbit

Part of the mo. lesson in the Mar 16 Issue of Prestwood eMag
ASP Classic Code Snippet:
 A flashcard from our ASP Classic Flashcards Library
 A code snippet from our ASP Classic Code Snippets Page
ASP Classic Empty String Check (Len(s&vbNullString))

In ASP Classic, you have to add an empty string to the value being compared in order to get consistent results. For example, add &"" to your string varilable or it's code equivalent &vbNullString. Then compare to an empty string or verify it's length to 0 with Len.


All these will work for variables unassigned, set to "", or set to Null:

If s&"" = "" Then
  Response.Write("<br>Quotes with &'' say null is empty")
End If
 
If Len(s&"") = 0 Then
  Response.Write("<br>Len with &'' says null is empty")
End If
 
If Len(s&vbNullString) = 0 Then
  Response.Write("<br>Using vbNullString also works!")
End If
Switch to longer article version of ASP Classic Empty String Check (Len(s&vbNullString)) (ASP Classic Coding)

More Info


Comments

1 Comments.
Share a thought or comment...
Comment 1 of 3

Thank you so much! Beautiful and profound explanation!

---
Atos
Posted 12 years ago

Comment 2 of 3

Thanks a lot. Find the solution after my half day analysis. Good Tip. Sensible.

---
Maheswaran
Posted 12 years ago

Comment 3 of 3

thank you very much indeed, deep clear explanation

---
manuele
Posted 9 years ago
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1272A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile


Linked Certification Question(s)

The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

Advanced

1 Advanced Level Question

Question #1: Multiple Choice

Will the following code print "Hello, World!" or will it cause an error?

<%@LANGUAGE='VbScript'%>
<%Option Explicit%>
<html>
<body>
<%
Dim s
 
s = Null
  
If Len(s) = 0 Then
  Response.Write("Hello, World!")
End If
%>
</body>
</html>
Answer:
1. 

It will cause an error.

2. 

It will print "Hello, World!".


 KB Article #102039 Counter
46154
Since 9/17/2009
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2022 Prestwood IT Solutions.   [Security & Privacy]