Let the games begin.
VB Code:
Function CountLines( _ ByRef pszFilename As String, _ ByVal fUnicode As Boolean _ ) As Long Dim hFile As Long Dim lFilelen As Long Dim lpPos As Long Dim chBuf() As Byte Dim lMax As Long Dim i As Long Dim lStep As Long Const CHUNKSIZE = 1024 hFile = FreeFile() Open pszFilename For Binary Lock Write As #hFile lFilelen = LOF(hFile) ReDim chBuf(CHUNKSIZE) lStep = -fUnicode + 1 Do While (lpPos < lFilelen) If ((lFilelen - CHUNKSIZE) < lpPos) Then _ ReDim chBuf(lFilelen - lpPos) Get #hFile, lpPos + 1, chBuf lMax = UBound(chBuf) For i = 0 To lMax Step lStep If (chBuf(i) = 13) Then _ CountLines = CountLines + 1 Next i lpPos = lpPos + CHUNKSIZE Loop Close #hFile End Function
I haven't tried optimising it yet, but it's a start![]()




Reply With Quote