Returns a substring of a String expression starting at the specified character position and consisting of a specified number of characters.
...Mid( string_exp, first_pos, length )
Prerequisites
None
Parameters
string_exp
A required String expression. string_exp can be a String variable, constant, function, method or a concatenation of these String elements.
first_pos
A required numeric expression. This specifies the position of the first character to be extracted and returned. Note, unlike the Substring method, the first character position is 1 rather than 0.
length
An optional numeric expression. This value specifies the number of characters to be copied into the returned value. If length is 0, the returned substring will be empty. If length is not specified, all of the remaining characters in the string_exp starting at the first_pos will be copied.
Remarks
This function evaluates a String expression, extracts a substring from its value, and returns the results. The substring is specified by its starting character position in string_exp and the number of characters to be extracted.
Examples
Dim stg_result As String ' Create a string variable
stg_result = Mid("aBcdef", 4, 2) ' stg_result will be set to "de"
See Also