Retour chariot txt

sahbi_z Messages postés 2 Date d'inscription lundi 6 mars 2006 Statut Membre Dernière intervention 9 janvier 2009 - 9 janv. 2009 à 09:24
cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 - 9 janv. 2009 à 19:12
bonjour

j'ai un fichier texte  sans retour chariot cad écrit sur une seule ligne .
svp  ya t-il un code vb qui me permet de forcer un retour a la ligne   avant un chiffre   fixe qui se repete .

merci

5 réponses

Gildeplomb Messages postés 101 Date d'inscription samedi 29 décembre 2012 Statut Membre Dernière intervention 1 novembre 2023
9 janv. 2009 à 10:17
Bonjour

Voir du coté de la fonction split( fichier,separateur)

Touche F1 pour l'aide

Gil
0
cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 79
9 janv. 2009 à 10:20
Salut
"un chiffre   fixe qui se repete" : Il y a un chiffre dans le texte qui peut servir de marqueur ?

Une fois que tu as chargé en mémoire le contenu du fichier, il ne s'agit plus que de faire du découpage.
Si tu as une borne (ton chiffre fixe), tu peux transformer ta chaine en un tableau de chaine grace à Split :
   Dim monTableau() As String
   monTableau = Split(maChaine, "1234")
L'inconvénient, c'est que le chiffre servant de borne disparait de la chaine.
Si tu dois le revoir dans chaque chaine, il te faudra faire une boucle de réinsertion :
   For r = 0 To UBound(monTableau)
      monTableau(r) = monTableau(r) & "1234"
   Next r

Vala
Jack, MVP VB
NB : Je ne répondrai pas aux messages privés

<hr />Le savoir est la seule matière qui s'accroit quand on la partage (Socrate)
0
cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 79
9 janv. 2009 à 10:22
Autre idée, je pense moins lourde : Remplacer ton chiffre par un retour à la ligne :
   maChaine = Replace(maChaine, "1234", "1234" & vbCrLf)
0
sahbi_z Messages postés 2 Date d'inscription lundi 6 mars 2006 Statut Membre Dernière intervention 9 janvier 2009
9 janv. 2009 à 11:05
bonjour
merci pour votre réponse
un message d'erreur  se pressente
"erreur d'exécution 9"
"l'indice 'appartient pas a la sélection "

merci

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="ProgId" content="Word.Document" /><meta name="Generator" content="Microsoft Word 11" /><meta name="Originator" content="Microsoft Word 11" /><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CSAHBI%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" /><link rel="Edit-Time-Data" href="file:///C:%5CDOCUME%7E1%5CSAHBI%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_editdata.mso" /><!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><style><!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
@page Section1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
--></style><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Tableau Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]--><!--[if gte vml 1]><v:shapetype id="_x0000_t75"
coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:278.25pt;
height:154.5pt'>
<v:imagedata src="file:///C:\DOCUME~1\SAHBI\LOCALS~1\Temp\msohtml1\01\clip_image001.png"
o:title=""/>
</v:shape><![endif]--><!--[if !vml]--><!--[endif]-->
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 79
9 janv. 2009 à 19:12
lol
C'est bien de donner l'erreur, mais encore faudrait-il savoir sur quelle instruction ...
Pendant que tu y es, donnes nous un exemple de texte à scinder.
0
Rejoignez-nous