Replaces a specified number of characters in a string variable with characters from another string.
Mid(stringvar, start[, length]) = string
The Mid statement syntax has these parts:
Part |
Description |
stringvar |
Name of string variable to modify. |
start |
Character position in stringvar where the replacement of text begins. |
length |
Number of characters to replace. If omitted, all of string is used. |
string |
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 Another statement (MidB) is provided for use 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.
Mid Function.
This example uses the Mid statement to replace a specified number of characters in a string variable with characters from another string.
MyString = "The dog jumps" ' Initialize string.(MyString, 5, 3) = "fox" ' MyString = "The fox jumps".(MyString, 5) = "cow" ' MyString = "The cow jumps".(MyString, 5) = "cow jumped over" ' MyString = "The cow jumps".(MyString, 5, 3) = "duck" ' MyString = "The duck jumps".