The IsArray Function

Using the IsArray function you can test whether a variable is an array. The IsArray function returns True if the variable is an array or False if it's not an array. Let's do another hands-on.

© Hands-On 7-8: Using the IsArray Function

1. In a new module, enter the code of the IsThisArray procedure, as shown below.

2. Run the IsThisArray procedure to examine its results.

Sub IsThisArray()

' declare a dynamic array Dim tblNames() As String Dim totalTables As Integer Dim counter As Integer Dim db As Database

Set db = CurrentDb

' count the tables in the open database totalTables = db.TableDefs.Count

Part I

' specify the size of the array ReDim tblNames(1 To totalTables)

' enter and show the names of tables For counter = 1 To totalTables - 1

tblNames(counter) = db.TableDefs(counter).Name Debug.Print tblNames(counter) Next counter

' check if this is indeed an array If IsArray(tblNames) Then

MsgBox "The tblNames is an array." End If End Sub

0 0

Post a comment