I've got an array that is used to create a binary file. This file has a certain format to it (26 bytes per record) but for it to write 1068 items (size of array) takes 35 seconds??? If I create a file for Output and add the same values is takes 1 second???
I can't see why it takes so long to create the binary file? Can anyone help shed some light on this for me?
VB Code:
Public Sub CreateDataManFile(tMainData() As TypeGraphData) Dim intFile As Integer Dim DataManFile As String Dim sString As String * 14 Dim i As Long Dim j As Integer Dim dateDay As Byte Dim dateMonth As Byte Dim dateYear As Integer DataManFile = App.Path & "\Lintz.mmd" 'Check if dataman file exists and if so delete it If Dir$(DataManFile) <> "" Then Kill DataManFile End If intFile = FreeFile Open DataManFile For Binary Access Write As #intFile Debug.Print "Start Time Without Date = " & Now For i = 0 To UBound(tMainData) '1068 items Put #intFile, LOF(intFile) + 1, tMainData(i).fAmt 'This gets the day, month, year depending on users regional settings Call GetCurrentDate(dateDay, dateMonth, dateYear, CDate(tMainData(i).dDate)) 'fill in 18 bytes as data inbetween is not used j = 5 Do Until j = 23 Put #intFile, LOF(intFile) + 1, CByte(0) j = j + 1 Loop 'Add Day Put #intFile, LOF(intFile) + 1, dateDay 'Add Month Put #intFile, LOF(intFile) + 1, dateMonth 'Add Year Put #intFile, LOF(intFile) + 1, dateYear DoEvents Next Close #intFile Debug.Print "End Time = " & Now '35 seconds End Sub




Reply With Quote