This documentation is archived and is not being maintained.

Visual Basic for Applications Reference

Visual Studio 6.0

Mid Statement

See Also    Example    Specifics

Replaces a specified number of characters in a Variant (String) variable with characters from another string.


Mid(stringvar, start[, length]) = string

The Mid statement syntax has these parts:

Part Description
stringvar Required. Name of string variable to modify.
start Required; Variant (Long). Character position in stringvar where the replacement of text begins.
length Optional; Variant (Long). Number of characters to replace. If omitted, all of string is used.
string Required. String expression that replaces part of stringvar.


The number of characters replaced is always less than or equal to the number of characters in stringvar.

Note   Use the MidB statement with byte data contained in a string. In the MidB statement, start specifies the byte position within stringvar where replacement begins and length specifies the numbers of bytes to replace.