Hello there,
i was trying to load text files(tab delimited) in a flexgrid, i tried two methods to add each line in the grid, the procedure was fine with small files; but once i load a big file (some of my text files are 100,000+ rows) i get out of memory error (#7) ...
is there any way to handle this error and continue loading the file where it stoped?
my loading code looks like this:
Sub cmdBtnDXP_Click()
InitMSHFlexGrid1 ' to set number of columns
' first method
Dim hFile As Integer
Dim sLines() As String, sTxt As String
Dim n As Double, nCount As Double
With CommonDialog1
.CancelError = True
.Flags = cdlOFNFileMustExist + cdlOFNHideReadOnly
.Filter = "Data Exported Files (*.DXP - *.TXT)|*.DXP;*.TXT|All Files (*.*)|*.*|Text Files (*.txt)|*.txt|"
On Error Resume Next
.ShowOpen
If Err.Number <> cdlCancel Then
hFile = FreeFile
Open .FileName For Input As #hFile
sTxt = Input(LOF(hFile), hFile)
Close #hFile
sLines = Split(sTxt, vbCrLf)
nCount = UBound(sLines)
For n = 1 To nCount
MSHFlexGrid1.AddItem sLines(n)
Next
End If
End With
'Secon method
Dim intFile As Integer
intFile = FreeFile
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #intFile
Do While Not EOF(1)
Line Input #intFile, textLine
MSHFlexGrid1.AddItem textLine
Loop
Close #intFile
End If
End Sub
many thanks..