mytaurus2000
Technical User
I have code that finds the correct string in my find button, but how do i code to search for the next occurance.
For e.g. I can not believe that you can
If I hit the find button it will highlight the first occurence of can, but if I hit the find next it will hightlight the next occurence.
Code for the Find button
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Target = txtTarget.Text
FoundPos = InStr(txtMemo.Text, Target)
txtMemo.SelectionStart = IIf(FoundPos > 0, FoundPos - 1, 0)
txtMemo.SelectionLength = IIf(FoundPos > 0, Len(Target), 0)
txtMemo.Focus()
btnFindNext.Enabled = IIf(FoundPos > 0, True, False)
End Sub
For e.g. I can not believe that you can
If I hit the find button it will highlight the first occurence of can, but if I hit the find next it will hightlight the next occurence.
Code for the Find button
Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Target = txtTarget.Text
FoundPos = InStr(txtMemo.Text, Target)
txtMemo.SelectionStart = IIf(FoundPos > 0, FoundPos - 1, 0)
txtMemo.SelectionLength = IIf(FoundPos > 0, Len(Target), 0)
txtMemo.Focus()
btnFindNext.Enabled = IIf(FoundPos > 0, True, False)
End Sub