|To read and write data quickly from arrays to file (or vice-versa)
consider using Put and Get. This is significantly faster than reading and writing the
array one entry at a time using Input #, Write # or Print #. The example below
writes the entire contents of an array to a file in one step.
Dim arrLongValue(1 To 100000) As Long
Dim IntNum As Integer
'populate array here
IntNum = FreeFile
Open "C:\Temp\Test.dat" For Binary As intNum
Put #intNum, arrLongValue
For files contain data of different data types, consider using a user defined variable
into which each file line can be read. See example below:
' Define user-defined type.
ID As Integer
Name As String * 20
Dim MyRecord As Record, Position
' Open sample file for random access.
Open "TESTFILE" For Random As #1 Len = Len(MyRecord)
' Define record number.
Position = 3
' Read third record.
Get #1, Position, MyRecord