我所做的搜索功能是有效的,但是它只找到一次单词,我的困难是我不能获得搜索功能来读取整个文本框并找到在搜索文本框中输入的所有单词
Private Sub btnSearch_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSearch.Click
Dim Search As String
Dim Where As Long
' Get search string from user.
Search = InputBox("Enter text to be found:")
' Find string in text.
Where = InStr(TheText.Text, Search)
If Where <> 0 Then
TheText.Focus()
TheText.SelectionStart = Where - 1
TheText.SelectionLength = Len(Search)
Else
MsgBox("String not found.")
End If
txtR.Text = CountWords(Search)
Sorting.Items.Add(txtR.Text)
End Sub
发布于 2011-11-07 04:46:11
Text box控件不允许这样的多选,但Rich Textbox控件允许。它本质上与您拥有的代码是相同的,但是您需要一个位置编号来跟踪最近的查找和循环,直到不再有搜索字符串的实例。
发布于 2012-02-01 10:07:23
如果您只想显示匹配的项,则可以使用正则表达式。符合条件的项将包含在RegEx.Matches集合中。请参阅http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.matches.aspx#Y527
https://stackoverflow.com/questions/8010712
复制相似问题