Description
The Mid$
function returns the specified portion of a string.
Syntax
var$ = Mid$(
Parameters
<string$>
: string from which to extract.
<start>
: numeric, position in <string$>
from which to extract. The first character position is 1. If <start>
is greater than the number of characters in <string$>
, var$
is set to an empty string. If <start>
is negative, the extraction starts at position 1.
<length>
: numeric, number of characters to be extracted. If <length>
is negative or 0, var$
is set to an empty string.
Return Value
var$
: string, return value containing the substring. If the length of <string$>
(including the character starting at <start>
) is less than <length>
, all the characters from <start>
to the end of <string$>
are returned in var$
.
See Also
Left$, Right$, ExtractBetween$
Examples
a$ = Mid$("bcdefg", 2, 2) ' Returns "cd" in a$
a$ = Mid$("bcdefg", 2, 0) ' Returns "" in a$
a$ = Mid$("bcdefg", 0, 2) ' Returns "bc" in a$