Meilleur auteur de réponses
Recherche ds un fichier txt

Question
-
Réponses
-
Bonjour, voici de tête, non vérifié :
sub fichier() Dim p As Integer dim r as long dim l as long dim ligne_fichier as string dim recherche as string ChDrive App.Path ' rep courant ChDir App.Path ' rep courant recherche = "texte recherché" l = 0 p = FreeFile Open "nom_fichier.txt" For Input As p do while eof(p) = false l = l + 1 Line Input #p, ligne_fichier r = InStr(1, ligne_fichier, recherche, 1) if r <> 0 then msgbox("Trouvé : ligne = " & l & " : Octet = " & r & vblf & ligne_fichier", vbexclamation) exit do end if loop close(p) end sub
Joseph Attila PUSZTAY
EhJoe Logiciels Romans Ecrire
Toutes les réponses
-
Bonjour, voici de tête, non vérifié :
sub fichier() Dim p As Integer dim r as long dim l as long dim ligne_fichier as string dim recherche as string ChDrive App.Path ' rep courant ChDir App.Path ' rep courant recherche = "texte recherché" l = 0 p = FreeFile Open "nom_fichier.txt" For Input As p do while eof(p) = false l = l + 1 Line Input #p, ligne_fichier r = InStr(1, ligne_fichier, recherche, 1) if r <> 0 then msgbox("Trouvé : ligne = " & l & " : Octet = " & r & vblf & ligne_fichier", vbexclamation) exit do end if loop close(p) end sub
Joseph Attila PUSZTAY
EhJoe Logiciels Romans Ecrire -
-