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

TextRange Object

Visual Studio .NET 2003

Represents a single, contiguous section of text in a text document.

DTE

   Documents

      Document

         TextDocument

            TextRanges

               TextRange

[Visual Basic .NET]
Public Interface TextRange
    Inherits IDispatch
[Visual Basic 6]
Class TextRange
[C++]
interface TextRange : IDispatch
[C#]
public interface TextRange : IDispatch
[JScript .NET]
public interface TextRange extends IDispatch

Remarks

The section of text is enclosed by a pair of EditPoint Objects.

TextRange objects are used when you have regular expressions with tagged subexpressions. A collection of ranges is returned, one for each matched subexpression, and their properties are read-only.

For general text manipulation, it is recommended that you instead use objects such as TextSelection or EditPoint, because the TextSelection object relates directly to the selection visible on the screen. When the selection area changes, the object's coordinates change, and vice-versa. As a result, a text selection cannot be used to represent an arbitrary range of text without disrupting that text selection.

Requirements

Namespace: EnvDTE

File: dte.olb

Example

Sub TextRangeExample()
   Dim objTxtSel As TextSelection
   Dim colRanges As TextRanges
   Dim objRange As TextRange
   Dim objEP As EditPoint

   Set objTxtSel = ActiveDocument.Selection
   Set colRanges = objTxtSel.TextRanges
   For Each objRange In colRanges
      objRange.StartPoint.Insert "/*"
      objRange.EndPoint.Insert "*/"
   Next
End Sub

See Also

Properties, Methods, and Events | EditPoint Object | TextRange Object | TextSelection Object

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.