here is my code:

FileNumber = FreeFile()
Open "C:\TestFile.txt" For Random As FileNumber Len = Len(rec)
Do Until EOF(FileNumber)
i = i + 1
Get FileNumber, i, rec
Loop

'rec is the UDT;
'variable i will return the number of records
'that are in the file

the problem i have is when i delete a record
the length of the UDT still remains in the file
which therefore, in my case, variable i will return an
incorrect number.

if anyone knows a way to remove the dead space from
a deleted record in a random access file let me know