共用方式為


EditPoint2.ReplaceText 方法 (Object, String, Int32)

以指定的文字取代選取的文字。

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

語法

'宣告
Sub ReplaceText ( _
    PointOrCount As Object, _
    Text As String, _
    Flags As Integer _
)
void ReplaceText(
    Object PointOrCount,
    string Text,
    int Flags
)
void ReplaceText(
    [InAttribute] Object^ PointOrCount, 
    [InAttribute] String^ Text, 
    [InAttribute] int Flags
)
abstract ReplaceText : 
        PointOrCount:Object * 
        Text:string * 
        Flags:int -> unit 
function ReplaceText(
    PointOrCount : Object, 
    Text : String, 
    Flags : int
)

參數

  • PointOrCount
    型別:System.Object
    必要項。可能是 TextPoint 物件或是決定要取代文字的整數。

備註

ReplaceText 會將結束點和 PointOrCount 之間的文字換成 Text,嘗試保留中斷點資料標記和具名捷徑等位置。

範例

Sub ReplaceTextExample()
   Dim objTextDoc As TextDocument
   Dim objMovePt As EditPoint
   Dim objEditPt As EditPoint, iCtr As Integer

   ' 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")
   objMovePt = objTextDoc.EndPoint.CreateEditPoint
   objEditPt = objTextDoc.StartPoint.CreateEditPoint

   ' Insert ten lines of text.
   For iCtr = 1 To 10
      objEditPt.Insert("This is a test." & Chr(13))
   Next iCtr
   objEditPt.StartOfDocument()
   objMovePt.EndOfDocument()
   ' Replace all occurrences of "test" with "thing."
   MsgBox("Replacing all text with a new string...")
   objEditPt.ReplaceText(objMovePt, "ALL TEXT REPLACED WITH THIS SENTENCE.", vsEPReplaceTextOptions.vsEPReplaceTextAutoformat)
End Sub

.NET Framework 安全性

請參閱

參考

EditPoint2 介面

ReplaceText 多載

EnvDTE80 命名空間