Hello gint32,
Perhaps this annotated version will help you. This does not address your issue of placing this on a UserForm. As snb mentioned, we would need to see both the workbook and full code to provide you with a solution.
Sub TestMacro()
' Random access file records are User Defined Type structures with a fixed number of bytes.
' The record length must be included in the Open statement else VBA will not know how many bytes to read or write.
' If the file specified by pathname doesn't exist, it is created when a file is opened in Append, Binary, Output, or Random modes.
Open "C:\folder\file.dat" For Random Shared As #1 Len = Len(Ent)
' Divide the number of bytes in the file by 364, using Integer math, to determine the number of records.
For Num_OF_Records = 1 To LOF(1) \ 364
' Read a record from the dat file. 'Put' is used to write a record using the User Defined Type (UDT) data, 'Get' is used to read a record and copy the data into the UDT.
Get #1, Num_OF_Records, Ent
' Format the date from the dat file.
EDate = Val(Format(EDate.A_Date, "yymmmdd"))
' Determine if a row is to be added.
If (ShowAll_Flag = 1) Or (ShowAll_Flag = 0 And EDate >= CurrentDate) Then
If Trim(Ent.TmpID) = Range("EmpID") And Trim(Ent.mrk) <> "DELETED" Then
' Increment the row number
Row_Num = Row_Num + 1
' Copy the dat file values to the worksheet tanges.
With Ent
Range("'OReg'!A" & Row_Num) = Trim(.A_Date)
Range("'OReg'!B" & Row_Num) = Trim(.P_Prefer)
End With
End If
End If
Next Num_OF_Records
Close #1
End Sub