Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15621

OUT of memory in VB&

$
0
0
Code:


'i call with
Call FileLoadToArray(asFileContents, sFileName)

Function FileLoadToArray(ByRef asLines() As String, ByVal sFileName As String) As String
   
    Dim iFileNum As Long, lFileLen As Long
    Dim sBuffer As String
   
    On Error GoTo ErrFailed
   
    iFileNum = FreeFile
    Open sFileName For Binary Access Read As #iFileNum
    'Get the size of the file
    lFileLen = LOF(iFileNum)
    If lFileLen Then
        'Create output buffer
        sBuffer = String(lFileLen, " ")
        'Read contents of file
        Get iFileNum, 1, sBuffer
        'Split the file contents vbCrLf
        asLines = Split(sBuffer, vbCrLf)
    End If
   
    Close #iFileNum
    FileLoadToArray = ""
   
    Exit Function
   
ErrFailed:
    Debug.Assert False
    Debug.Print Err.Description
    FileLoadToArray = Err.Description
    'Close file
    If iFileNum Then
        Close #iFileNum
    End If
End Function

in a vba for excel work perfect, but in vb6 have error in: Get iFileNum, 1, sBuffer

note:
the code are in a form
Attached Images
 

Viewing all articles
Browse latest Browse all 15621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>