1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| Dim j As Integer = 0
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
j = 0
Dim i As Integer
strTexte = Me.RichTextBox1.Text
strChaine = TextBox1.Text
For i = 0 To strTexte.Length - strChaine.Length 'Step 1
If strTexte.Substring(i, strChaine.Length) = strChaine Then
Me.RichTextBox1.Focus()
Me.RichTextBox1.SelectionStart = i
Me.RichTextBox1.SelectionLength = strChaine.Length
Exit For
End If
j += 1
Next
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim i As Integer
j += strChaine.Length
For i = j To strTexte.Length - strChaine.Length 'Step 1
If strTexte.Substring(j, strChaine.Length) = strChaine Then
Me.RichTextBox1.Focus()
Me.RichTextBox1.SelectionStart = i
Me.RichTextBox1.SelectionLength = strChaine.Length
Exit Sub
End If
j += 1
Next i
End Sub |
Partager