Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Tip: NULL vs. Zero Length Strings    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Access Tip NULL vs Zero Length Strings
Jeff Martin 

14 years ago
In my VBA programming I like to use:

Name=vbNullString

rather than:

Name = ""


Dim Name as string

Name = Empty
Name = vbNullString
Name =

All return true.


According to VB6 testing for an empty string is faster when done this way.

LenB(Text$) = 0  

Rather then

Text$ =

LenB the byte equivalent of Len is faster than Len and the test for an inequality is faster than a greater then or less than sign.  LenB never returns a neg number.

Testing for Text$ = "" takes 6 bytes of RAM each time you use it.  A VBA string is only a pointer to a character array.  The address in memory pointed to by this variable points to the start of a character array.  The array is preceded by 4 bytes showing the length of the string in bytes, and terminates with a 2-byte null terminator.   So using a "' to declare an empty string results in a array size of 0 and will contain the 4 byte  length data, and the 2 byte terminator

VbNullString still returns a pointer but one that does not point to any character array resulting in no 4 byte length field or 2 byte terminator.

VbNullString is a string having a value of 0 and is not the same as a ZLS

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Tip: NULL vs. Zero Length Strings.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/9/2026 5:57:44 AM. PLT: 1s