Export (0) Print
Expand All
Cut
Run
Expand Minimize

FindText Method (TextSelection Object)

Visual Studio .NET 2003

Inserts text, overwriting the existing text.

[Visual Basic .NET]
Public Function FindText( _
   ByVal Pattern As String, _
   Optional ByVal Flags As Integer = 0 _
) As Boolean
[Visual Basic 6]
Function FindText( _
   ByVal Pattern As String, _
   Optional ByVal Flags As Long = 0 _
) As Boolean
[C++]
HRESULT __stdcall FindText(
   BSTR Pattern,
   long Flags,
   /* [out, retval] */ VARIANT_BOOL* retVal
);
[C#]
public bool FindText(
   string Pattern,
   int Flags
);
[JScript .NET]
public function FindText(
   Pattern : String,
   Flags : int
) : Boolean

Parameters

Pattern
Required. The text to find.
Flags
Optional. A vsFindOptions constant indicating the search options to use.

Return Value

True if the the text is found, False if not.

Remarks

FindText searches for the given text string from the selected text'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.

Example

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

See Also

Applies To: TextSelection Object

Show:
© 2014 Microsoft