There are several ways to do this. The previous comment looks like it should handle it, but if not, try something like this:
dim strData(2) as String * 8
dim iVariableCntr as integer
Open "theCfile.bin" for binary as #1
for iVariableCntr =0 to 2
if LOF(1) >= 8 then ' LOF= length of remaining file
bytData(iVariableCntr, iByteCntr) = input$(8,#1)
else
bytData(iVariableCntr, iByteCntr) = input$(LOF(1),#1)
end if
next iVariableCntr
close #1
Again, there are other ways, and this is not necessarily the best. After reading, the three variable values are stored as a string in the three array elements. If you want the bytes, they're easy to get: asc(mid$(strData(n), byte#, 1)). But if you want them as a number, you'd have to do a lot of work to assemble the pieces.
Main Topics
Browse All Topics





by: iNSTAPosted on 2003-04-24 at 16:04:36ID: 8391807
Option Explicit
Private Type myType
myDouble(3) As Double
End Type
Private Sub Form_Load()
Dim myData As myType
Dim myFile As Long
Dim i As Long
Dim j As Long
Dim numRecords As Long
myFile = FreeFile
Kill "myFile.dat"
Open "myFile.dat" For Random As #myFile Len = Len(myData)
For i = 1 To 50
For j = 0 To 3
myData.myDouble(j) = (100 * i) + j
Next
Put #myFile, i, myData
Next
Close #myFile
Open "myFile.dat" For Random As #myFile Len = Len(myData)
numRecords = (LOF(myFile) / Len(myData))
Debug.Print "There are"; numRecords; "records."
For i = 1 To numRecords
Get #myFile, i, myData
For j = 0 To 3
Debug.Print myData.myDouble(j);
Next
Debug.Print
Next
Close #myFile
End Sub
-iNSTA