rechercher dans une richtextbox
bonjour a tousse:D
j'ai fait un petit bloc note avec un bouton rechercher quand je clique dessus sa ouvre une autre form ou il y a une textbox et un bouton rechercher
sa marche très bien seulement quand je recherche un mot ou une lettre quand je clique sur rechercher rien ne se passe c'est quand je ferme la fenetre rechercher donc je ferme la form et c'est la qu'il me sélectionne le mot que j'ai rechercher.
donc en faite je voudrait juste ne pas avoir besoins de fermer ma form
voila mon code si vous avez des idée pour l'améliorer je suis preneur
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rechercher.Click
Dim i, j As System.Int32
strTexte = Form1.RichTextBox.Text
strChaine = TextBox1.Text
For i = 0 To strTexte.Length - strChaine.Length Step 1
If strTexte.Substring(i, strChaine.Length) = strChaine Then
j += 1
Form1.RichTextBox.SelectionStart = i
Form1.RichTextBox.SelectionLength = strChaine.Length
End If
Next
End Sub
End Class |