Nothing Keyword


Nothing Keyword

Syntax

     Nothing 

Description

The Nothing keyword represents an undefined instance of an object. Reference types that have not yet been assigned an instance have a value of Nothing.

Value types never have a value of Nothing; they always have a value assigned. Assigning Nothing to a value type assigns that variable the default value for that type. For instance, in the statement:

     Dim unassignedValue As Integer = Nothing 

the unassignedValue variable is assigned zero, the default value for Integer variables.

Usage at a Glance

  • To test a value for Nothing, do not use the equals comparison operator (=). Instead, use the IsNothing function or the Is operator.

         If (IsNothing(someVariable) = True) Then...     If (someVariable Is Nothing) Then... 

See Also

Is Operator, IsNot Operator, IsNothing Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net