The Array Function

The Array function allows you to create an array during code execution without having to first dimension it. This function always returns an array of Variants. Using the Array function you can quickly place a series of values in a list. The CarInfo procedure in the following hands-on creates a fixed-size, one-dimensional, three-element array called auto.

© Hands-On 7-7: Using the Array Function

1. In a new module, enter the following CarInfo procedure.

2. Run the CarInfo procedure and examine the results.

Sub CarInfo()

Dim auto As Variant auto = Array("Ford", "Black", "1999") MsgBox auto(2) & " " & auto(1) & ", " & auto(3)

MsgBox auto(2) & " " & auto(1) & ", " & auto(3) End Sub

0 0

Post a comment