Private Function GetTextFileLineNum(ByVal strFile As String) As Long
Dim lFN As Long
Dim chrTmp1 As Byte, chrTmp2 As Byte
Dim lLC As Long
lFN = FreeFile
lLC = 0
Open strFile For Binary As #lFN
Do Until EOF(lFN)
Get #lFN, , chrTmp2
If chrTmp1 = 13 And chrTmp2 = 10 Then
lLC = lLC + 1
End If
chrTmp1 = chrTmp2
Loop
GetTextFileLineNum = lLC + 1
Close #lFN
End Function
Function getlinescount(txtpath As String) As Long
Dim filetxt As String, x As Variant, i As Integer
filetxt = String(FileLen(txtpath), " ")
Open txtpath For Binary As 1
Get #1, , filetxt
Close 1
x = Split(filetxt, vbCrLf)
getlinescount = UBound(x) + 1
Set x = Nothing
End Function
Private Sub Form_Click()
MsgBox getlinescount("c:\windows\win.ini")
End Sub