<div class="meta" robots="noindex">

</div>

Method

# Mid

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `String.Middle<string.Middle>` as a replacement.

</div>

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

## Description

Returns a portion of a `string</api/data_types/string>`. The first character is numbered 1.

## Usage

``` xojo
result = Mid(source, start [, length ])
```

| Part   | Type                               | Description                                                                                                                           |
|--------|------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| result | `String</api/data_types/string>`   | The portion of *source* from *start* and continuing for *length* characters or all remaining characters if *length* is not specified. |
| source | `String</api/data_types/string>`   | Required. The string from which characters are returned.                                                                              |
| start  | `Integer</api/data_types/integer>` | Required. The position of the first character to be returned.                                                                         |
| length | `Integer</api/data_types/integer>` | Optional. The number of characters to return from *source*.                                                                           |

## Notes

To determine the number of characters in a `string</api/data_types/string>`, use the `String.Length<string.length>` function.

The <span class="title-ref">Mid</span> function works properly with international text.

## Sample code

These examples use the <span class="title-ref">Mid</span> function to return portions of a `string</api/data_types/string>`.

``` xojo
Var s As String
s = Mid("This is a test", 6) ' returns "is a test"
s = Mid("This is a test", 11, 4) ' returns "test"

s = "This is a test"
s = s.Mid(11, 4) ' returns "test"
```

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

This example converts the text string in TextField1 to hex and writes the result to TextField2:

``` xojo
TextField2.Text = ""
For i As Integer = 1 To TextField1.Text.Length
  TextField2.Text = TextField2.Text + "&h" + Hex(Mid(TextField1.Text, i, 1).Asc)
Next
```

## Compatibility

All project types on all supported operating systems.

## See also

`Asc</api/math/asc>`, `Chr</api/text/chr>`, `String.IndexOf<string.indexof>`, `String.Left<string.left>`, `String.Length<string.length>`, `String.Right<string.right>` functions.
