The information in this article applies to:
SYMPTOMSWhen you use the Mid$(), Right$() or Left$() function, you may receive the following error message:
CAUSE
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN
RISK. Microsoft provides this macro code 'as is' without warranty of any
kind, either express or implied, including but not limited to the implied
warranties of merchantability and/or fitness for a particular purpose.
Mid$(<source$>, <start> [, <count>])where <source$> is the text string, <start> is the character position from which to start, and <count> is the number of characters to return. If no <count> parameter is specified, or if there are fewer than <count> characters in the text, the function returns all the characters from the <start> position to the end of the string. The following sample macro illustrates the error message described in the "Symptoms" section of this article:
The following sample macro returns the error because the length of Test$
minus one is a negative number (0 - 1 = -1):
NOTE: Word version 2.0 for Windows ignores a -1 value for the <count>
parameter. So in Word 2.0 all the characters from the first character
position to the end of the string are displayed in the message box. In the
first example, the string "hello" is displayed.
RESOLUTION
To keep this error from ocurring, first test the length of the string.
REFERENCES
Word Developer's Kit, version 6.0, page 594 Additional query words:
Keywords : kberrmsg kbmacro winword macword word7 word95 |
Last Reviewed: October 20, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |