The information in this article applies to:
SUMMARYIn Microsoft Word versions 5.0 and 5.5 for MS-DOS, the MID function provides the ability to extract a range of characters from a string of text or numbers. MORE INFORMATION
By itself, the MID function can operate only on a variable of fixed
length, or on a string where the value desired is a known number of
places from the beginning of the string.
This macro looks at the variable "zipcode", reads from character "1"
(in this case, the first character is "0"), and extracts five digits.
If zipcode=01234-5678, "Result" is now "01234".To find the last four digits of the zip code, the LEN function must be introduced with a negative number, as in the following example:
If zipcode=01234-5678, LEN(zipcode)-3 returns "5678".To find the last character in a string of any length, use the value "-0" after the LEN function as follows:
If zipcode=01234-5678, LEN(zipcode)-0 returns "8". "Result" is now "5678".The two functions count characters in different ways. MID counts from left to right, where the first character is "1". LEN with a negative number counts from right to left, starting with "-0". To find the start character of "LETTER.DOC", count as follows:
The syntax of the MID command is as follows:
MID(stringname,start, range) where "stringname" is the string to be operated on, "start" is the character to begin extracting from, and "range" is the number of characters to be extracted. The syntax of the LEN command is as follows: LEN(stringname) where "stringname" is the string to be operated upon. Note: The opening chevron (<<) is created by pressing CTRL+[. The closing chevron (>>) is created by pressing CTRL+]. Single angle brackets ( < and > ) should be typed as displayed. Additional query words: 5.00 5.50 5.00a 5.00b 5.50a
Keywords : kbmacro |
Last Reviewed: December 20, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |