IncrementalSearch.AppendCharAndSearch 方法

將字元加入至 ISearch 模式比對,並且對新字串搜尋一次。

命名空間:  EnvDTE80
組件:  EnvDTE80 (在 EnvDTE80.dll 中)

語法

'宣告
Function AppendCharAndSearch ( _
    Character As Short _
) As vsIncrementalSearchResult
vsIncrementalSearchResult AppendCharAndSearch(
    short Character
)
vsIncrementalSearchResult AppendCharAndSearch(
    short Character
)
abstract AppendCharAndSearch : 
        Character:int16 -> vsIncrementalSearchResult 
function AppendCharAndSearch(
    Character : short
) : vsIncrementalSearchResult

參數

  • Character
    型別:System.Int16
    轉譯成 Unicode 字元的短整數 (Short Integer)。

傳回值

型別:EnvDTE80.vsIncrementalSearchResult
vsIncrementalSearchResult 列舉型別。

備註

AppendCharAndSearch 將新字元加入至搜尋模式 (請參閱 Pattern 屬性) 並且以目前的方向搜尋新的模式比對。

如果找到符合項目,編輯器的選取範圍會移到此符合項目並且傳回 Found 值。

如果找不到符合項目,選取範圍不會變動並且傳回 Failed 值。新字元可能無法附加到搜尋模式。若要進一步使用 AppendCharAndSearch,錯誤字元必須從模式中移除。

請使用 AscW() 功能,提供字元的 Unicode 字碼指標。

範例

Sub testIS()
    ' Set variables for text pane.
    Dim tp As EnvDTE80.TextPane2
    tp = CType(DTE.ActiveDocument.ActiveWindow.Object.ActivePane, _
    TextPane2)
    ' Start an incremental search forward from
    ' the current insertion point in the document.
    tp.IncrementalSearch.StartForward()
    ' Add the character "a" to the search pattern.
    tp.IncrementalSearch.AppendCharAndSearch(Asc("a"))
    ' Display the status of the search mode.
    'MsgBox("ISearch status: " & _
    tp.IncrementalSearch.IncrementalSearchModeOn.ToString)
    ' Perform incremental search using the pattern ("a").
    tp.IncrementalSearch.SearchWithLastPattern()
    ' After the search, exit incremental search mode.
    tp.IncrementalSearch.Exit()
End Sub

.NET Framework 安全性

請參閱

參考

IncrementalSearch 介面

EnvDTE80 命名空間

其他資源

How to: Search for Text Incrementally

How to: Search a Document Incrementally