You want to open a file for Random (Access) and best if you set it with a fixed length record size. This allows you to read and write records to a record number.
Here is a demo for johnno for tracking Blood tests;
You create a data entry form for entering the record to file file or reading records out.
Here is a demo for johnno for tracking Blood tests;
Code: (Select All)
'Tutorial (with help from Wiki):
' save this bas file in the folder where you want you BloodData.dat file to go first!
Type Blood
date As String * 10
level As Integer
comment As String * 50
End Type
'Make a record:
Dim Shared Record As Blood, lenRecord&, nRecs&
lenRecord& = Len(Record)
' start up the data file
Open "BloodData.dat" For Random As #1 Len = lenRecord&
Record.date = "2022/11/18"
Record.level = 101
Record.comment = "This is my comment."
'Store a record:
Put #1, 1, Record
nRecs = LOF(1) / lenRecord&
Print "number recs:"; nRecs ' good 1 lets get it
' get record
Get #1, 1, Record
Print Record.date; ":"; Record.level; ", "; Record.comment
' stick another record in there
nRecs = nRecs + 1
Record.date = "2022/11/19"
Record.level = 105
Record.comment = "This is my next comment."
Put #1, nRecs, Record
' check records
nRecs = LOF(1) / lenRecord&
Print "number recs:"; nRecs ' good 1 lets get it
For i = 1 To nRecs
Get #1, i, Record
Print Record.date; ":"; Record.level; ", "; Record.comment
NextYou create a data entry form for entering the record to file file or reading records out.
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever

