Description This subroutine loads values into a specified array (can be multi-dimensional). If there is a problem the subroutine sets an error and returns without modifying the parameters.
Syntax LoadTable array, data
Parameters array (Double Array) The array that will hold the values. This array must be dimensioned before use.
data (Variant) The data to load into the table. The data can be in the form of a string, with each column enclosed in []'s.
Examples One-dimensional array:
Sub Main Dim arry(3) As Double Dim vals As Variant Dim ii As Long
vals = "1 2 3 4" LoadTable arry, vals For ii = 0 To UBound( arry,1 ) Print arry( ii ) Next ii End Sub
Two-dimensional array having 3 rows and 4 columns:
Sub Main Dim arry(2,3) As Double Dim vals As Variant Dim ii As Long
vals = "[1 2 3] [4 5 6] [7 8 9] [10 11 12]" LoadTable arry, vals For ii = 0 To UBound( arry, 1 ) Print arry( ii, 0 ) & Chr(9) & arry( ii, 1 ) & Chr(9) & arry( ii, 2 ) & Chr(9) & arry( ii, 3 ) Next ii End Sub
This code outputs the following: 1 4 7 10 2 5 8 11 3 6 9 12
Related Topics
|