' Ch. 10 Hands-On Programming Exercise #4 -
'
' Write a comma-delimited text file with three records (integers)
' on each of 5 lines. Create a command button that uses a double
' nested loop and an Input # statement to input all 15 elements
' into a 5 x 3 two-dimensional array. As a second exercise, place
' the same data into an MS Excel comma-delimited (.csv) file and do
' the same thing.
' You must create a data file named HandOn4.txt with
' 5 rows of data each containing 3 integer values
' separated by commas. The file must be saved in the
' C:\Temp folder.
Option Explicit
Private Sub Command1_Click()
Dim Row As Integer
Dim Column As Integer
Dim MyArray(1 To 5, 1 To 3) As Integer
Open "C:\Temp\HandOn4.txt" For Input As #1
For Row = 1 To 5
For Column = 1 To 3
Input #1, MyArray(Row, Column)
Form1.Print MyArray(Row, Column); " ";
' This statement is only necessary to check the program
Next Column
Form1.Print ' Only necessary to check the program
Next Row
Close #1
End Sub