Returns a FixStr (String) containing a specified number of characters
from a string.
Mid(string, start[, length]) |
The Mid function syntax has these named arguments:
Part | Description |
string | Required. String expression from which characters are returned. If string contains Null, Null is returned. |
start |
Required; Long. Character position in string at which the part to be taken begins. If start is greater than the number of characters in string, Mid returns a zero-length string (""). |
length |
Optional; Long. Number of characters to return. If omitted or if there are fewer than length characters in the text (including the character at start), all characters from the start position to the end of the string are returned. |
To determine the number of characters in string, use the Len
function.
The Mid$ form returns String values. The Mid form returns
FixStr values.
Dim MyString, FirstWord, LastWord, MidWords MyString = "Mid Function Demo" ' Create text string. FirstWord= Mid(MyString, 1, 6) ' Returns "Mid". LastWord = Mid(MyString, 16, 3) ' Returns "Function". MidWords = Mid(MyString, 8) ' Returns "Function Demo". |
See Also |
Len Function, Left Function, Right Function |