Class

# Range

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to get the starting position, length, and end position of a `StyleRun</api/text/stylerun>`.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                 | Type                               | Read-Only | Shared |
|--------------------------------------|------------------------------------|-----------|--------|
| `EndPosition<range.endposition>`     | `Integer</api/data_types/integer>` | ✓         |        |
| `Length<range.length>`               | `Integer</api/data_types/integer>` |           |        |
| `StartPosition<range.startposition>` | `Integer</api/data_types/integer>` |           |        |

## Property descriptions

<div id="range.endposition">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Range.EndPosition

**EndPosition** As `Integer</api/data_types/integer>`

> The ending position of the `StyleRun</api/text/stylerun>`.
>
> This property is read-only.

<div id="range.length">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Range.Length

**Length** As `Integer</api/data_types/integer>`

> The length of the `StyleRun</api/text/stylerun>`.

<div id="range.startposition">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Range.StartPosition

**StartPosition** As `Integer</api/data_types/integer>`

> The starting position of the `StyleRun</api/text/stylerun>`. The first position is zero.

## Notes

A `StyleRun</api/text/stylerun>` is a series of characters with the same style attributes in a `StyledText</api/text/styledtext>` object. A block of `StyledText</api/text/styledtext>` can be thought of as a group of `StyleRuns</api/text/stylerun>` that are appended to each other. Use the <span class="title-ref">Range</span> class to access the position of a `StyleRun</api/text/stylerun>` within the styled text.

## Sample code

The following example loops through the `StyleRuns</api/text/stylerun>` in a block of `StyledText</api/text/styledtext>` that is displayed in a `TextArea</api/user_interface/desktop/desktoptextarea>`. It uses the StartPos and Length properties of the <span class="title-ref">Range</span> class to get the position of each `StyleRun</api/text/stylerun>` and displays it and the text of each `StyleRun</api/text/stylerun>` in a `ListBox</api/user_interface/desktop/desktoplistbox>`.

``` xojo
Var count As Integer = TextArea1.StyledText.StyleRunCount  ' get the number of StyleRuns

For i As Integer = 0 To count - 1
  ListBox1.AddRow(TextArea1.StyledText.StyleRunRange(i).StartPos.ToString)
  ListBox1.CellTextAt(i, 1) = TextArea1.StyledText.StyleRunRange(i).Length.ToString
  ListBox1.CellTextAt(i, 2) = TextArea1.StyledText.StyleRun(i).Text
Next
```

## Compatibility

|                       |                       |
|-----------------------|-----------------------|
| **Project Types**     | Console, Desktop, Web |
| **Operating Systems** | All                   |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `Paragraph</api/text/paragraph>`, `StyledText</api/text/styledtext>`, `StyleRun</api/text/stylerun>` classes; `DesktopTextArea</api/user_interface/desktop/desktoptextarea>` control.

</div>
