VB.NET如何实现文本搜索?

来源:百度知道 编辑:UC知道 时间:2024/06/28 09:09:02
如何在textbox里实现文本搜索,在搜索到关键字之后自动跳到那里,烦请敲下代码并说明一下,谢谢!

我学这没多久,试下吧。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim src As String
Dim where As String
src = TextBox1.Text
where = InStrRev(main.tbx1.Text, src, main.tbx1.SelectionStart - 1)
If where Then
main.tbx1.Focus()
main.tbx1.SelectionStart = where - 1
main.tbx1.SelectionLength = src.Length
Else
MsgBox("没有找到", , "提示")
End If
End Sub