Export (0) Print
Expand All

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 (
	[InAttribute] Object PointOrCount
)
String GetText (
	/** @attribute InAttribute() */ Object PointOrCount
)
function GetText (
	PointOrCount : Object
) : String

Parameters

PointOrCount

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

Return Value

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

Community Additions

ADD
Show:
© 2014 Microsoft