TextSelection.ReplaceText 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 ReplaceText ( _
Pattern As String, _
Replace As String, _
vsFindOptionsValue As Integer _
) As Boolean
'Usage
Dim instance As TextSelection
Dim Pattern As String
Dim Replace As String
Dim vsFindOptionsValue As Integer
Dim returnValue As Boolean
returnValue = instance.ReplaceText(Pattern, _
Replace, vsFindOptionsValue)
bool ReplaceText(
string Pattern,
string Replace,
int vsFindOptionsValue
)
bool ReplaceText(
[InAttribute] String^ Pattern,
[InAttribute] String^ Replace,
[InAttribute] int vsFindOptionsValue
)
function ReplaceText(
Pattern : String,
Replace : String,
vsFindOptionsValue : int
) : boolean
Parameters
Pattern
Type: System.StringRequired. The text to find.
Replace
Type: System.StringThe text to replace.
vsFindOptionsValue
Type: System.Int32Optional. A vsFindOptions constant indicating the search options to use.
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 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.
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.