JohnGtrs
Messages postés125Date d'inscriptionvendredi 27 février 2009StatutMembreDernière intervention 6 septembre 2015
-
8 juin 2012 à 23:19
JohnGtrs
Messages postés125Date d'inscriptionvendredi 27 février 2009StatutMembreDernière intervention 6 septembre 2015
-
9 juin 2012 à 03:04
Bonjour,
Je ne connais pas du tout le langage VBS, seulement je dois y toucher pour écrire dans un fichier. Pouvez-vous m'aider a transcrire cet algo en VBS s'il vous plait ? Je vous en serais très reconnaissant.
k : entier
ligne1, ligne 2 : chaine
fic1 : chaine <- "lechemindudossier"
fic2 : chaine <- "lechemindudossier"
fic3 : chaine <- "lechemindudossier"
Debut
ouvrir(fic2, Lecture)
ouvrir(fic3, Ecriture)
lire(fic2, ligne2)
tant que non fin(fic2)
ouvrir(fic1, Lecture)
lire(fic1, ligne1)
k <-- 1
tantque non fin(fic1) et ligne2 <> ligne1
k <-- k + 1
lire(fic1, ligne1)
fintantque
si ligne2 = ligne1 alors
ecrire(fic3, k)
finsi
fermer (fic1)
lire(fic2, ligne2)
fintantque
fermer (fic2)
fermer (fic3)
fin
JohnGtrs
Messages postés125Date d'inscriptionvendredi 27 février 2009StatutMembreDernière intervention 6 septembre 2015 9 juin 2012 à 03:04
Bon finalement j'ai réussi :
dim objFSO, objFile, objFiles, objFiless, Texte, Textes
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject" )
Set objFiles = objFSO.OpenTextFile("C:\Scripts\fic2.txt", ForReading)
Set objFiless = objFSO.OpenTextFile("C:\Scripts\fic3.txt", ForWriting)
Textes = objFiles.ReadLine
While Not objFiles.AtEndOfStream
Set objFile = objFSO.OpenTextFile("C:\Scripts\fic1.txt", ForReading)
Texte = objFile.ReadLine
k = 1
While Not objFile.AtEndOfStream And Texte <> Textes
k = k + 1
Texte = objFile.ReadLine
Wend
If Texte = Textes Then
objFiless.WriteLine k
End If
objFile.Close
Textes = objFiles.ReadLine
Wend
objFiles.Close
objFiless.Close