Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim i As Integer Dim strTexte As String Dim strChaine As String strTexte = RichTextBox1.Text strChaine = "OUI" For i = 0 To strTexte.Length - strChaine.Length Step 1 If strTexte.Substring(i, strChaine.Length) = strChaine Then RichTextBox1.SelectionStart = i RichTextBox1.SelectionLength = strChaine.Length RichTextBox1.SelectionColor = Color.Blue i += 1 End If Next i End Sub Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load RichTextBox1.Text = "ceci est un texte pour détecter le OUI et non le NON, mais si il ya plusieurs OUI on les détecte aussi" End Sub End Class
16 mars 2018 à 12:25