> FirstLines    


Reads the First Lines of a file.

' FirstLines
' http://www.utteraccess.com/wiki/FirstLines
' Code courtesy of UtterAccess Wiki
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
' You are free to use this code in any application,
' provided this notice is left unchanged.
' rev  date                          brief descripton
' 1.0  2013-10-27                    strPath: A string that contains the Path where the File is located.
'                                    strFile: A string that contains the Name of the File.
'                                    lngNodes: The Number of Lines to be read.

Public Function FirstLines(strPath As String, _
                          strFile As String, _
                         lngNodes As Long) As String
   Dim oFSO    As Scripting.FileSystemObject
   Dim oTSt    As Scripting.TextStream
   Dim strPF   As String
   Dim strSL   As String
   Dim i       As Long
   strPF = strPath & "\" & strFile
   Set oFSO = New Scripting.FileSystemObject
   Set oTSt = oFSO.OpenTextFile(strPF, ForReading)
   With oTSt
       For i = 1 To lngNodes
           strSL = strSL & .ReadLine & vbCrLf
       Next i
   End With
   Set oFSO = Nothing
   FirstLines = strSL

End Function

Creative Commons License
FirstLines by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.