2011-11-04 80 views
1

我已經完成的搜索功能正在工作,但它只能找到一次單詞,我有困難的是,我不能讓搜索功能來閱讀整個文本框,並找到所有在搜索文本框中輸入的詞我如何搜索文本框中的視覺基本文本

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 

回答

0

文本框控件不允許多個選擇,但Rich Textbox控件確實如此。它本質上與您擁有的代碼相同,但您需要一個位置號來跟蹤最近的查找和循環,直到沒有更多搜索字符串實例。