Use Random Access Files to save a user defined data type : Random Access Files « File Path « VBA / Excel / Access / Word






Use Random Access Files to save a user defined data type

 
Private Type Employee
     empID As String * 8
     empName As String * 20
     empAge As Integer
     empStatus As String * 10
     empSalaryClass As String * 1
End Type
Sub GetMaxRecNum()
    Dim empData As Employee
    Dim empDataLen As Long
    Dim filePath As String
    filePath = ActiveWorkbook.Path & "\Employees.txt"
    empDataLen = FileLen(filePath)
    Debug.Print empDataLen / Len(empData) + 1
End Sub

 








Related examples in the same category

1.Random Access Files
2.Gets the desired record from the file and writes the fields to the worksheet.