Difference between revisions of "Null"

From HashVB
Jump to: navigation, search
m (Added VB6 header)
m (Too many "basically"s)
Line 13: Line 13:
 
* vbNullChar - This is the Null character mentioned earlier and is the same as Chr$(0)
 
* vbNullChar - This is the Null character mentioned earlier and is the same as Chr$(0)
 
* vbNullString - A Null string is a pointer to nothing (0) which is subtly different to an empty string (a pointer to a zero length string). In most cases these are interchangable in VB.
 
* vbNullString - A Null string is a pointer to nothing (0) which is subtly different to an empty string (a pointer to a zero length string). In most cases these are interchangable in VB.
* Nothing - The Nothing keyword is used when working with objects and is basically a pointer to nothing. This is the state of all uninitialized object variables and is also used to release an object.
+
* Nothing - The Nothing keyword is used when working with objects and is a pointer to nothing. This is the state of all uninitialized object variables and is also used to release an object.

Revision as of 15:09, 3 May 2006

float
 This article is based on Visual Basic 6. Find other Visual Basic 6 articles.

Null in the computer world basically means "nothing".

It is normally used in 3 main contexts:

  • Null parameter/variable - This basically means "pointer to nothing" and is used by some functions to mean you don't have anything to pass it.
  • Null character - Null characters have an ASCII code of 0 and are sometimes used to mark the end of strings or to separate multiple values.
  • Null values in databases - Null is used to show the database field has nothing in it. This is different to 0 or an empty string ("") which are both valid values provided this is specified as such in the table creation or by the DB driver.

There are several "Nulls" in VB, all of which are easily confused.

Uses of Null in VB:

  • vbNull - This should only be used when working with the VarType() function. You will have very little cause to use this.
  • vbNullChar - This is the Null character mentioned earlier and is the same as Chr$(0)
  • vbNullString - A Null string is a pointer to nothing (0) which is subtly different to an empty string (a pointer to a zero length string). In most cases these are interchangable in VB.
  • Nothing - The Nothing keyword is used when working with objects and is a pointer to nothing. This is the state of all uninitialized object variables and is also used to release an object.