cs_vde
Messages postés2Date d'inscriptionmercredi 13 mars 2002StatutMembreDernière intervention14 mars 2002
-
13 mars 2002 à 17:24
cs_oliver68
Messages postés117Date d'inscriptionlundi 17 décembre 2001StatutMembreDernière intervention10 mars 2003
-
15 mars 2002 à 10:10
Bonjour,
je cherche le moyen d'utiliser VB pour modifier un simple fichier texte, certaines lignes commencent par un 1 et d'autre par un 2, les lignes commencant par 1 sont en quelque sorte un header et celles commencant par un 2 sont les details des header chaque header comprend au moin un ligne de detail... je montre
1 COMMANDE POUR MONSIEUR XXX
2 NUMERO D'ARTICLE 1258474
2 NUMERO D'ARTICLE 1258475
1 COMMANDE POUR MONSIEUR WWW
2 NUMERO D'ARTICLE 1258448
1 COMMANDE POUR MONSIEUR ZZZ
2 NUMERO D'ARTICLE 1258442
2 NUMERO D'ARTICLE 1258478
2 NUMERO D'ARTICLE 1258411
Le probleme c'est qu'il y a un retour a la ligne apres chaque header ou detail, je voudrais arriver a ca :
1 COMMANDE POUR MONSIEUR XXX 2 NUMERO D'ARTICLE 1258474 2 NUMERO D'ARTICLE 1258475
1 COMMANDE POUR MONSIEUR WWW 2 NUMERO D'ARTICLE 1258448
1 COMMANDE POUR MONSIEUR ZZZ 2 NUMERO D'ARTICLE 1258442 2 NUMERO D'ARTICLE 1258478 2 NUMERO D'ARTICLE 1258411
c'est a dire que un header et ses details se trouvent sur la meme ligne mais toujours une nouvelle ligne par header.
cs_oliver68
Messages postés117Date d'inscriptionlundi 17 décembre 2001StatutMembreDernière intervention10 mars 2003 14 mars 2002 à 14:49
salut,
tente voir :
sub fichier()
close
open "c:\fichier1.txt" for input as #1
open "c:\fichier2.txt" for append as #2
line input #1, laligne
nouvelleligne = laligne
do while not eof(1)
line input #1, laligne if mid(laligne, 1, 1) 2 then nouvelleligne nouvelleligne & " " & laligne
if mid(laligne, 1, 1) = 1 then
print #2, nouvelleligne
nouvelleligne = laligne
end if
loop
print #2, nouvelleligne
close
kill "c:\fichier1.txt"
name "c:\fichier2.txt" as "c:\fichier1.txt"