Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

EditPoint.GetText Method

Gets the text between the current location and the specified location in the buffer.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)
string GetText(
	Object PointOrCount
)

Parameters

PointOrCount
Type: System.Object

Required. Either a TextPoint object or a number of characters.

Return Value

Type: System.String
A string of text located between the current location and the specified location in the buffer.

GetText returns a string representing the text between the edit point and PointOrCount. If the argument is an integer, then GetText returns a string representing the specified number of characters following the edit point (one is added for an implied newline sequence at the end of each line).

If the argument is negative, then GetText returns the text before the edit point.

Sub GetTextExample()
   Dim objTextDoc As TextDocument
   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")
   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()
   msgbox("The results of GetText: " & Chr(13) & objeditpt.GetText(4))
End Sub
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.