ArrayDims (function)

Syntax

ArrayDims(arrayvariable)

Description

Returns an Integer containing the number of dimensions of a given array.

Comments

This function can be used to determine whether a given array contains any elements or if the array is initially created with no dimensions and then redimensioned by another function, such as the FileList function, as shown in the following example.

Example

This example allocates an empty (null-dimensioned) array; fills the array with a list of filenames, which resizes the array; then tests the array dimension and displays an appropriate message.

Sub Main()

  Dim f$()
  FileList f$,"c:\*.bat"
  If ArrayDims(f$) = 0 Then
    MsgBox "The array is empty."
  Else
    MsgBox "The array size is: " & (UBound(f$) - UBound(f$) + 1)
  End If
End Sub

See Also

LBound (function); UBound (function); Arrays (topic)

More information

A