Difference between revisions of "Null"

From HashVB
Jump to: navigation, search
(bit more description)
Line 4: Line 4:
 
* 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 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 [[Wikipedia:ASCII|ASCII]] code of 0 and are sometimes used to mark the end of strings or to separate multiple values.
 
* Null character - Null characters have an [[Wikipedia:ASCII|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 show the database field has nothing in it. This is different to 0 or an empty string ("") which are both valid 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.
  
 
There are several "Nulls" in VB, all of which are easily confused.
 
There are several "Nulls" in VB, all of which are easily confused.

Revision as of 09:26, 30 August 2005

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.

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 basically a pointer to nothing. This is the state of all uninitialized object variables and is also used to release an object.