Uso questo codice per riempire un array e successivamente fare il loop delle righe "storate".
con file di piccole dimensioni funziona benissimo ma con il file originale che è di 250.000 MB e contiene circa 2.000.000 di righe ho l'errore descritto in :
Dim strBuffer As String: strBuffer = Space(FileLen(strFileName))<<<<<<<
il mio codice:
- Codice: Seleziona tutto
Option Explicit '
Dim m_strRows() As String '
Private Sub cmdLoad_Click()
'
Dim strFileName As String
strFileName = "\\01p\FTP_WebTeam\OUT\TAB.txt"
Dim strBuffer As String: strBuffer = Space(FileLen(strFileName))
Dim intFreeFile As Integer: intFreeFile = FreeFile
Open strFileName For Binary As intFreeFile ' open file
Get intFreeFile, , strBuffer
Close intFreeFile
'
Dim lngRow As Long
m_strRows() = Split(strBuffer, vbCrLf)
strBuffer = ""
'
For lngRow = 0 To UBound(m_strRows)
'Debug.Print m_strRows(lngRow)
Next
'
For lngRow = 0 To UBound(m_strRows)
'Debug.Print Replace(m_strRows(lngRow), ",", vbTab)
Next
Dim lngCol As Long, strCols() As String
Dim strDelimiter As String: strDelimiter = ","
For lngRow = 0 To UBound(m_strRows)
strCols() = Split(m_strRows(lngRow), ",")
If UBound(strCols) >= 0 Then
strBuffer = strCols(0)
For lngCol = 1 To UBound(strCols)
strBuffer = strBuffer & _
vbTab & strCols(lngRow)
Next
End If
Debug.Print strBuffer
Next
'
End Sub
nota:nel codice ci sono vari test per il loop degli elementi dell'array ma questo non incide sull'errore.