Extract a substring from a string, starting at a given position.
Syntax Mid(string, start_position, [number_of_chars]) Mid$(string, start_position, [number_of_chars]) Key string The text string or string expression. start_position The start character in the string. The first character is 1. number_of_chars The number of characters to extract. default= all characters after start_position.
The Mid() function can be used in VBA or in an SQL query.
Mid() will return a Variant, Mid$() will return a String.
You should use Mid() if there is any chance of a Null value, since assigning Null to a String will raise an error.
Use the MidB function with byte data contained in a string. Instead of specifying the number of characters to return, length specifies the number of bytes.
Dim strDemo as String
strDemo = Mid("The world is everlasting",5,5)
“Love's dominion, like a king's, admits of no partition” ~ Ovid
Left - Extract a substring from a string
Right - Extract a substring from a string