This documentation is archived and is not being maintained.

ReplaceWith Property

Visual Studio .NET 2003

Sets or returns the replacement text for a replacement operation.

[Visual Basic .NET]
Public Property ReplaceWith() As String
[Visual Basic 6]
Property Get ReplaceWith() As String
Property Let ReplaceWith( _
   ByVal NewValue As String _
HRESULT __stdcall get_ReplaceWith(
   /* [out, retval] */ BSTR* retVal
HRESULT __stdcall put_ReplaceWith(
   /* [in] */ BSTR NewValue
public string ReplaceWith {get; set;}
[JScript .NET]
public function get ReplaceWith() : String
public function set ReplaceWith(
   NewValue : String


Required. The text to be used in the replacement operation.


Sub ReplaceWithExample()
   Dim objTextDoc As TextDocument
   Dim objEditPt As EditPoint
   Dim iCtr As Integer
   Dim objFind As Find

   ' Create a new text file.
   DTE.ItemOperations.NewFile("General\Text File")

   ' Get a handle to the new document and create an EditPoint.
   objTextDoc = DTE.ActiveDocument.Object("TextDocument")
   objEditPt = objTextDoc.StartPoint.CreateEditPoint
   objFind = objTextDoc.DTE.Find

   ' Insert ten lines of text.
   For iCtr = 1 To 10
      objEditPt.Insert("This is a test." & Chr(13))
   Next iCtr

   ' Set the find options.
   objFind.Action = vsFindAction.vsFindActionReplaceAll
   objFind.Backwards = False
   objFind.FilesOfType = "*.txt"
   objFind.FindWhat = "test"
   objFind.KeepModifiedDocumentsOpen = True
   objFind.MatchCase = False
   objFind.MatchInHiddenText = False
   objFind.MatchWholeWord = True
   objFind.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
   objFind.ReplaceWith = "NEW THING"
   objFind.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
   objFind.SearchPath = "c:\temp"
   objFind.SearchSubfolders = False
   objFind.Target = vsFindTarget.vsFindTargetCurrentDocument
   ' Perform the Find operation.
End Sub

See Also

FindReplace Method

Applies To: Find Object