RichTextBox atteindre le mot suivant

Résolu
francoislaba Messages postés 44 Date d'inscription mardi 10 mai 2005 Statut Membre Dernière intervention 4 janvier 2006 - 7 oct. 2005 à 15:23
francoislaba Messages postés 44 Date d'inscription mardi 10 mai 2005 Statut Membre Dernière intervention 4 janvier 2006 - 7 oct. 2005 à 16:04
Bonjour,

Voici un code qui fonctionne bien, qui a pour but de rechercher un mot dans une richtextbox . Il trouve bien le premier mot mais je n'arrive pas à atteindre le suivant... Quelqu'un pourrait m'aider à faire fonctionner ce code de manière à se qu'il atteigne tout les mots rechercherchés?
Jèai juste besoin du code complémentaire pour atteindre le mot suivant, je m'arrangerai ensuite pour qu'il stock chaque valeur dans un tableau à la suite.


Dim returnValue
As
Integer = -1



Dim start
As
Integer



Dim fax
As
String


Text = "fax:."



If Text.Length > 0
And start >= 0
Then



Dim indexToText
As
Integer = RichTextBox1.Find(Text, start, _


RichTextBoxFinds.MatchCase)



If indexToText >= 0
Then


returnValue = indexToText


RichTextBoxtableau.Text = returnValue


fax = Microsoft.VisualBasic.Mid(RichTextBox1.Text, returnValue + 6, 10)


RichTextBoxtableau.Text = fax



End
If



End
If

François

2 réponses

cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
7 oct. 2005 à 15:32
Il te suffit de changer l'index de départ de ta recherche dans la fonction Find, par exemple :



'Première recherche :

Dim indexToText
As
Integer = RichTextBox1.Find(Text, start, _


RichTextBoxFinds.MatchCase)



If indexToText >= 0
Then




returnValue = indexToText




RichTextBoxtableau.Text = returnValue




fax = Microsoft.VisualBasic.Mid(RichTextBox1.Text, returnValue + 6, 10)




RichTextBoxtableau.Text = fax




End
If


'Deuxième recherche :

indexToText
= RichTextBox1.Find(Text,
indexToText + 1
, _



RichTextBoxFinds.MatchCase)



If indexToText > = 0
Then





returnValue = indexToText





RichTextBoxtableau.Text = returnValue





fax = Microsoft.VisualBasic.Mid(RichTextBox1.Text, returnValue + 6, 10)





RichTextBoxtableau.Text = fax





End
If



_____________________________________________________________________
DarK Sidious

Un API Viewer (pour le VB, VB.NET, C, C# et Delphi) tout en français : www.ProgOtoP.com/popapi/
3
francoislaba Messages postés 44 Date d'inscription mardi 10 mai 2005 Statut Membre Dernière intervention 4 janvier 2006
7 oct. 2005 à 16:04
Merci, je l'ai ajouté à la suite et ai rajouté un goto pour qu'il recherhce jusqu'à la fin du texte..

Voici mon code quasi définitif qui fonctionne mais qui n'insère pas les valeurs trouvées à la ligne de ma seconde RichTextBox...


Dim returnValue
As
Integer = -1



Dim start
As
Integer



Dim fax
As
String



Dim compteur
As
String


Text = "fax:."



' Ensure that a search string has been specified and a valid start point.



If Text.Length > 0
And start >= 0
Then



' Obtain the location of the search string in richTextBox1.



Dim indexToText
As
Integer = RichTextBox1.Find(Text, start, _


RichTextBoxFinds.MatchCase)



' Determine whether the text was found in richTextBox1.



If indexToText >= 0
Then


returnValue = indexToText


RichTextBoxtableau.Text = returnValue


fax = Microsoft.VisualBasic.Mid(RichTextBox1.Text, returnValue + 6, 10)


RichTextBoxtableau.Text = fax


1:


indexToText = RichTextBox1.Find(Text, indexToText + 1, _


RichTextBoxFinds.MatchCase)



If indexToText >= 0
Then


returnValue = indexToText


RichTextBoxtableau.Text = returnValue


fax = Microsoft.VisualBasic.Mid(RichTextBox1.Text, returnValue + 6, 10)


RichTextBoxtableau.Text = fax



GoTo 1



End
If



End
If



End
If


Merci

François
3
Rejoignez-nous