Macro Fails If Optional Argument Uses Integer Data Type
Article ID: 112321
Article Last Modified on 10/11/2006
APPLIES TO
- Microsoft Excel 5.0 Standard Edition
This article was previously published under Q112321
SYMPTOMS
On page 128 in some versions of the "Visual Basic User's Guide," the
example that illustrates the REVERSE() function, contains the following
line of code:
Function Reverse (S As String, Optional ByVal n As Integer)
This code is incorrect. The optional argument "Optional ByVal n As Integer"
is incorrect because, as is stated in the paragraphs immediately preceding
the function code, all optional arguments must be of the Variant data type.
WORKAROUND
The correct line of code is the following:
Function Reverse (S As String, Optional ByVal n As Variant)
STATUS
This problem has been corrected in versions of the "User's Guide" dated
later than January 1994.
Additional query words: XL5
Keywords: kbprogramming KB112321