Compartir a través de


TextSelection.FindText Method

Searches for the given text from the active point to the end of the document.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
Function FindText ( _
    Pattern As String, _
    vsFindOptionsValue As Integer _
) As Boolean
bool FindText(
    string Pattern,
    int vsFindOptionsValue
)
bool FindText(
    [InAttribute] String^ Pattern, 
    [InAttribute] int vsFindOptionsValue
)
abstract FindText : 
        Pattern:string * 
        vsFindOptionsValue:int -> bool
function FindText(
    Pattern : String, 
    vsFindOptionsValue : int
) : boolean

Parameters

Return Value

Type: System.Boolean
A Boolean value indicating true if the text is found, false if not.

Remarks

FindText searches for the given text string from the text selection's active end to the end of the text document. The return value indicates whether the text is found. If the text is found, the edit point is moved to the beginning of the match. Otherwise, the edit location is unchanged.

If the matched pattern is a regular expression and contains tagged subexpressions, then the Tags argument returns a collection of TextRange objects, one for each tagged subexpression.

Examples

Sub FindTextExample()
   ' Before running this example, open a text document.
   Dim objSel As TextSelection = DTE.ActiveDocument.Selection

   ' Looks for the first occurence of the word, test, in the current 
   ' document. If found, the line is selected.
   If objSel.FindText("test", vsFindOptions.vsFindOptionsFromStart) Then
      objSel.SelectLine()
   End If
End Sub

.NET Framework Security

See Also

Reference

TextSelection Interface

EnvDTE Namespace