IsArray Function |
Microsoft.VisualBasic.Information
IsArray( varname )
A variable that may be an array
Boolean ( True or False )
Tests whether an object variable points to an array
If the variable passed to IsArray is an array or contains an array, True is returned; otherwise , IsArray returns False .
The following code displays True :
Dim s( ) As Integer = {1, 2} Dim t As Object t = s MsgBox(IsArray(t))
Due to the nature of Objects, it is not always obvious if an Object variable contains an array, especially if you have passed the variable to a function and the function may or may not have attached an array to the variable. Calling the array function UBound or trying to access an element in an array that does not exist will generate an error. In these situations, you should first use the IsArray function to determine if you can safely process the array.
An uninitialized array returns False . For example:
Dim strArr( ) As String Console.WriteLine(IsArray(strArr)) ' Returns False
Array-like data structures, such as the Collection object, return False when passed to the IsArray function.
In VB 6, the IsArray function returns True when passed an uninitialized array. In VB.NET, it returns False .