I have been quite busy so have not been on the forum for a while. I have the following code in a project that I am using to load the contents of a text file, so that I can make changes to it and save to a new text file.
I am getting an error on line 170 when it is trying to parse the lines in the file and load them into memory, I presume because the file has too many rows, because the code works fine on smaller text files.
I would like to avoid manually having to split this file into smaller files before processing. Does anyone know of a way that I could update this code, so that it will load this text file in sections and process them one at a time? This may also affect how the rest of my code runs, and I may then need to post back with that code, but I figured I would start here. Any help is much appreciated.
Thank you,
Kevin
Code:
Private Sub cmdBrowse_Click()
10 On Error GoTo cmdBrowse_Click_Error
20 MyInitDir = "I:\Tollfiles\EMI - Carroll Metaswitch"
30 With CommonDialog1
40 .CancelError = True
50 .DialogTitle = "Select File"
60 .Filter = "All files (*.*)|*.*|DAT files only (*.dat)|*.dat|EMI files only (*.EMI)|*.EMI|FGD files only (*.fgd)|*.fgd|Text files only (*.txt)|*.txt"
70 .FilterIndex = 1
80 .Flags = cdlOFNHideReadOnly Or cdlOFNOverwritePrompt Or cdlOFNPathMustExist
90 .InitDir = MyInitDir
100 .ShowOpen
110 End With
120 lblCurFilePath.Caption = CommonDialog1.FileName
130 txtNewFile.Text = CommonDialog1.FileName
140 glbOldFileName = CommonDialog1.FileName
150 Open glbOldFileName For Input As #1
160 s = Split(Input(LOF(1), 1), vbCrLf)
170 Close #1
180 glbTotal = UBound(s) + 1
190 lblRecTot.Caption = Format(glbTotal, "#,###,###")
200 Exit Sub
210 On Error GoTo 0
220 Exit Sub
cmdBrowse_Click_Error:
230 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdBrowse_Click of Form frmEditMeta110101 - Error on line " & Erl
End Sub
I am getting an error on line 170 when it is trying to parse the lines in the file and load them into memory, I presume because the file has too many rows, because the code works fine on smaller text files.
I would like to avoid manually having to split this file into smaller files before processing. Does anyone know of a way that I could update this code, so that it will load this text file in sections and process them one at a time? This may also affect how the rest of my code runs, and I may then need to post back with that code, but I figured I would start here. Any help is much appreciated.
Thank you,
Kevin