Macro Fails If Optional Argument Uses Integer Data Type (112321)



The information in this article applies to:

  • Microsoft Excel for Windows 5.0

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.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbProgramming KB112321