Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

???IsNull()... = Null... = ""... vbNullString??? 1

Status
Not open for further replies.

jmeckley

Programmer
Jul 15, 2002
5,269
US
I have entered a new project at work and have noticed something that boggles my mind.

through out the project the following statements are used to set a value to NULL:

IsNull()
=Null
= ""
vbNullString

I know to start with one and work my way through the NULL options until I do not get an error. However, being the curious one that I am, I would like to know the theory behind each one so I can be a more effective programmer.

The main difference I notice with these is that sometimes they pass a blank value to the SQL Server and some times they do not pass anything. A cell in the database will either read &quot;<Null>&quot; or &quot; &quot; (blank).

Jason
 
First off, &quot;&quot; is the same as vbNullString, which is not the same as Null. vbNullString is a zero length string, but is a valid string. That is to say that it can be manipulated by string functions, read as a string, concatenated as a string, and so forth. Null means that there is no data at all.

The IsNull function returns a boolean to indicate whether the expression contains no valid data.

If a variant v is assigned the value Null, as in v = Null, then it contains no data, and IsNull(v) returns true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top