mytaurus2000
Technical User
I am programming a simple word processor. How do you highlight the text after the word search? Here is my code:
Dim Target As String
Dim FoundPos As Single
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
FoundPos = InStr(1, txtMemo.Text, txtTarget.Text)
txtMemo.SelectionStart = IIf(FoundPos > 0, FoundPos - 1, 0)
txtMemo.SelectionLength = IIf(FoundPos > 0, Len(Target), 0)
End Sub
Dim Target As String
Dim FoundPos As Single
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
FoundPos = InStr(1, txtMemo.Text, txtTarget.Text)
txtMemo.SelectionStart = IIf(FoundPos > 0, FoundPos - 1, 0)
txtMemo.SelectionLength = IIf(FoundPos > 0, Len(Target), 0)
End Sub