< Public Function GetFile (Filename As String) As String (?)

Comments

'Reads and returns a file

Public Function GetFile (Filename As String) As String

    On Error GoTo Err_GetFile
    
    Dim FileNum As Integer
    Dim Buffer As String
    
    'Return no data if file does not exist
    If Not bFileExists(Filename) Then Exit Function
    
    FileNum = FreeFile
    Open Filename For Input As FileNum
    
    'Loop through lines of file
    Do
        
        'If not end of the file
        If Not EOF(FileNum) Then
        
            'Read a line
            Line Input #1, Buffer
            
            'Add line to buffer
            GetFile = GetFile & Buffer & vbCrLf
            
        End If
    
    Loop Until EOF(FileNum)
    
    'Close the file
    Close FileNum
Exit Function
Err_GetFile:
    
    GetFile = ""
    Err.Clear
    Exit Function
End Function


Copying, Return to index