Tout est dans le titre.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Function NbrLignFich(ChemNomFichier)
Dim oFSO, TotalFichier, NbrLigne, StrFichier
 
Set oFSO = CreateObject("Scripting.FileSystemObject")
NbrLigne = 0
 
If oFSO.FileExists(ChemNomFichier) Then
    Set TotalFichier = oFSO.GetFile(ChemNomFichier)
    If TotalFichier.Size <> 0 Then
        Set TotalFichier = oFSO.OpenTextFile(ChemNomFichier, 1, False)
        StrFichier = TotalFichier.ReadAll
        TotalFichier.Close
        Set TotalFichier = Nothing
        NbrLigne = UBound(Split(StrFichier, vbNewLine)) + 1
    End If
End If
 
Set oFSO = Nothing
NbrLignFich = NbrLigne
End Function
Utilisations:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
XX = NbrLignFich("C:\essais VB6\MemoHeuredhiver.txt")
 
If NbrLignFich("C:\essais VB6\MemoHeuredhiver.txt") > 10 Then _
MsgBox NbrLignFich("C:\essais VB6\MemoHeuredhiver.txt")