
IsDate Function | 345
The Language
Reference
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
IsArray Function
Class
Microsoft.VisualBasic.Information
Syntax
Dim result As Boolean = IsArray(varName)
varName (required; any variable)
A variable that may be an array
Description
The IsArray function indicates whether a variable is an array (True) or not (False).
Usage at a Glance
• Due to the nature of .NET objects, it is not always obvious that an Object vari-
able contains an array, since an entire array can be assigned to a simple
Object
variable. Calling array-specific functions like UBound or trying to access array
elements on a variable that is not an array will generate an error. If there is doubt
as to the nature of a variable, it should first be tested using the
IsArray function.
• An uninitialized array returns False. For example:
Dim unusedArray( ) As String
MsgBox(IsArray(unusedArray)) ' Displays "False"
• Array-like data structures, such as the Collection object, are not true arrays and
return
False when passed to the IsArray function.
Example
The following code displays “True,” even though the Object variable was not initially
declared as an array.
Dim multipleData( ) As Integer = {1, 2}
Dim singleData As Object
singleData = multipleData
MsgBox(IsArray(singleData)) ' Displays "True"
Version Differences
In VB 6, the IsArray function returns ...