SubStr Function

Purpose

Starting from position p, returns the next m characters of a string expression.

Syntax

SubStr[$](a$, p% [,m% [,char$]])

a$, char$:sexp
m%, p%:integer expression

Description

SubStr$(a$, p%, m%, char$) returns, starting from position p% (inclusive), up to m% characters of the string expression a$. If m% is not given, the whole string from position p% is returned. If m% specifies more characters than are present in a$, then the returned string is filled with character char$.

Example

Debug.Show

Local a$

a$ = "GFA Software Technologies GmbH"

Trace SubStr$(a$, 5, 9)         // Software

Trace SubStr(a$, 1, 3)          // GFA

Trace SubStr(a$, 5)             // Soft...

Trace SubStr(a$, 5, 35, "*")    // Software Technologies GmbH*********

Remarks

Without the optional $ character the function still returns a String data type and not a Variant.

See Also

String, Left$(), Right$(), Mid()

{Created by Sjouke Hamstra; Last updated: 23/10/2014 by James Gaite}