Mid[$] Function

Language Items List

Definition:

Returns the specified substring from another string expression.

Syntax:

Mid[$](strexpr, start[, length]


Syntax Description


strexpr String expression from which the specified characters are to be taken. This can be any string expression.

start Long expression that specifies the position in the source string at which to begin taking the designated number of characters.

length Numeric expression that specifies the number of characters to copy. If length is omitted or exceeds the number of characters in the string, then Mid returns all characters from start until the end of the string.

Details:

The value for start and length must be at least 1. If start exceeds the total number of characters in strexpr, Mid[$] returns a zero-length string. If there are fewer characters in the source string than in the expression specified in length, the Mid[$] function returns all characters from the start position to the end of the strexpr. It will not return a string that is larger than the original length of strexpr.

To find the number of characters in strexpr, use the Len function.

In the following example, both lines return "String."

mid(Sample String, 8, 6)

mid(
Sample String, 8)

This example returns "Str" as a result.

mid(Sample String,8,3) = Str

See Also:

Left$ Function
Len Function
Right$ Function