IsReference Function


IsReference Function

Class

Microsoft.VisualBasic.Information

Syntax

     Dim result As Boolean = IsReference(expression) 


expression (required; any)

The expression to be examined

Description

The IsReference function determines if expression contains reference type data (true) or value type data (False).

Usage at a Glance

  • IsReference returns true if expression is an array, since an array is a reference type.

  • Just because a variable has been declared to be of type Object does not mean that the IsReference function will return true when that variable is passed to it as an argument. Consider the following code:

         Dim generalData As Object     MsgBox(IsReference(generalData))       ' Displays "True"     generalData = New Employee     MsgBox(IsReference(generalData))       ' Displays "True"     generalData = 3     MsgBox(IsReference(generalData))       ' Displays "False"     generalData = "This is a string"     MsgBox(IsReference(generalData))       ' Displays "True" 

    The IsReference function returns TRue only if an Object variable is Nothing, or if its true data content is a reference type.

Version Differences

The IsReference function is new with VB in .NET.




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