OVH Cloud OVH Cloud

Remplacer 1 valeur dans 1 chaîne ???

4 réponses
Avatar
X
Bonjour,

Je cherche à remplacer la tabulation 9 ascii par un vide 0 ascii dans un
texte que je lis en tant que fichier .txt et que je passe en variable pour
travailler, avant de rebalancer dans un nouveau fichier, j'ai:

texte = Replace(texte, 1001, 0, vbBinaryCompare)
texte = Replace(texte, "1001", "0", vbBinaryCompare)

Ça me paraît étrange comme syntaxe ???

J'ai bien

For i = 1 To maxi
octet = Mid(ligne, i, 1)
ascii = Asc(octet)
j = len(ligne) - 1
if ascii = 9 then ligne = mid(ligne, 2, 1, j)

Mais ça c'est long sur un bouquin...

Je me demande aussi si Word saurait remplacer ascii 9 par ascii 0 (je
vais aussi poster dans Word) ???

Avez-vous une solution rapide ???

Merci.
--
ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************

4 réponses

Avatar
Christian Hugoud
Je ne suis pas certain de bien comprendre :

texte = Replace(texte, vbTab, "")

Christian


"X" <.> a écrit dans le message de news:

Bonjour,

Je cherche à remplacer la tabulation 9 ascii par un vide 0 ascii dans
un
texte que je lis en tant que fichier .txt et que je passe en variable pour
travailler, avant de rebalancer dans un nouveau fichier, j'ai:

texte = Replace(texte, 1001, 0, vbBinaryCompare)
texte = Replace(texte, "1001", "0", vbBinaryCompare)

Ça me paraît étrange comme syntaxe ???

J'ai bien

For i = 1 To maxi
octet = Mid(ligne, i, 1)
ascii = Asc(octet)
j = len(ligne) - 1
if ascii = 9 then ligne = mid(ligne, 2, 1, j)

Mais ça c'est long sur un bouquin...

Je me demande aussi si Word saurait remplacer ascii 9 par ascii 0 (je
vais aussi poster dans Word) ???

Avez-vous une solution rapide ???

Merci.
--
ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************







Avatar
Jacques93
Bonjour X,

s = Replace(s, vbTab, vbNullChar)

c'est à dire,

s = Replace(s, Chr$(9), Chr$(0))

X a écrit :
Bonjour,

Je cherche à remplacer la tabulation 9 ascii par un vide 0 ascii dans un
texte que je lis en tant que fichier .txt et que je passe en variable pour
travailler, avant de rebalancer dans un nouveau fichier, j'ai:

texte = Replace(texte, 1001, 0, vbBinaryCompare)
texte = Replace(texte, "1001", "0", vbBinaryCompare)

Ça me paraît étrange comme syntaxe ???

J'ai bien

For i = 1 To maxi
octet = Mid(ligne, i, 1)
ascii = Asc(octet)
j = len(ligne) - 1
if ascii = 9 then ligne = mid(ligne, 2, 1, j)

Mais ça c'est long sur un bouquin...

Je me demande aussi si Word saurait remplacer ascii 9 par ascii 0 (je
vais aussi poster dans Word) ???

Avez-vous une solution rapide ???

Merci.
--
ECRIRE
http://irolog.free.fr/ecrire/index.htm

LOGICIELS
http://irolog.free.fr

SITE
http://irolog.free.fr/joe/index.htm

FAQ VB
http://faq.vb.free.fr

PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
********************************************************









--
Cordialement,

Jacques.
Avatar
X
Ah, je connais peu les constantes VB, donc VBtab ça équivaut a ascii 9, ben
si c'est ça, et si c'est accepté, c'est bon, j'y vais de ce pas, merci :o)





"Christian Hugoud" a écrit dans le message de news:
%
| Je ne suis pas certain de bien comprendre :
|
| texte = Replace(texte, vbTab, "")
|
| Christian
|
|
| "X" <.> a écrit dans le message de news:
|
| > Bonjour,
| >
| > Je cherche à remplacer la tabulation 9 ascii par un vide 0 ascii dans
| > un
| > texte que je lis en tant que fichier .txt et que je passe en variable
pour
| > travailler, avant de rebalancer dans un nouveau fichier, j'ai:
| >
| > texte = Replace(texte, 1001, 0, vbBinaryCompare)
| > texte = Replace(texte, "1001", "0", vbBinaryCompare)
| >
| > Ça me paraît étrange comme syntaxe ???
| >
| > J'ai bien
| >
| > For i = 1 To maxi
| > octet = Mid(ligne, i, 1)
| > ascii = Asc(octet)
| > j = len(ligne) - 1
| > if ascii = 9 then ligne = mid(ligne, 2, 1, j)
| >
| > Mais ça c'est long sur un bouquin...
| >
| > Je me demande aussi si Word saurait remplacer ascii 9 par ascii 0 (je
| > vais aussi poster dans Word) ???
| >
| > Avez-vous une solution rapide ???
| >
| > Merci.
| > --
| > ECRIRE
| > http://irolog.free.fr/ecrire/index.htm
| >
| > LOGICIELS
| > http://irolog.free.fr
| >
| > SITE
| > http://irolog.free.fr/joe/index.htm
| >
| > FAQ VB
| > http://faq.vb.free.fr
| >
| > PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
| > http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
| > ********************************************************
| >
| >
| >
| >
| >
|
|
Avatar
X
Merci à vous deux, j'y vais :o)





"Jacques93" a écrit dans le message de news:
%
| Bonjour X,
|
| s = Replace(s, vbTab, vbNullChar)
|
| c'est à dire,
|
| s = Replace(s, Chr$(9), Chr$(0))
|
| X a écrit :
| > Bonjour,
| >
| > Je cherche à remplacer la tabulation 9 ascii par un vide 0 ascii
dans un
| > texte que je lis en tant que fichier .txt et que je passe en variable
pour
| > travailler, avant de rebalancer dans un nouveau fichier, j'ai:
| >
| > texte = Replace(texte, 1001, 0, vbBinaryCompare)
| > texte = Replace(texte, "1001", "0", vbBinaryCompare)
| >
| > Ça me paraît étrange comme syntaxe ???
| >
| > J'ai bien
| >
| > For i = 1 To maxi
| > octet = Mid(ligne, i, 1)
| > ascii = Asc(octet)
| > j = len(ligne) - 1
| > if ascii = 9 then ligne = mid(ligne, 2, 1, j)
| >
| > Mais ça c'est long sur un bouquin...
| >
| > Je me demande aussi si Word saurait remplacer ascii 9 par ascii 0
(je
| > vais aussi poster dans Word) ???
| >
| > Avez-vous une solution rapide ???
| >
| > Merci.
| > --
| > ECRIRE
| > http://irolog.free.fr/ecrire/index.htm
| >
| > LOGICIELS
| > http://irolog.free.fr
| >
| > SITE
| > http://irolog.free.fr/joe/index.htm
| >
| > FAQ VB
| > http://faq.vb.free.fr
| >
| > PRINCIPE D'UTILISATION DES NEWSGROUPS MICROSOFT
| > http://support.microsoft.com/directory/worldwide/fr/newsgroup/regles.htm
| > ********************************************************
| >
| >
| >
| >
| >
|
|
| --
| Cordialement,
|
| Jacques.