Microsoft KB Archive/297882

= PRB: Behavior of the Format Function Changes from Visual Basic 5.0 to Visual Basic 6.0 =

Article ID: 297882

Article Last Modified on 5/13/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.0 Learning Edition

-



This article was previously published under Q297882



SYMPTOMS
The Format function produces different results after you migrate a Visual Basic application from version 5.0 to version 6.0.



CAUSE
This problem can occur if you do not specify enough placeholders. The number of placeholder characters must equal the number of characters in the string that you are trying to format. In this case, the Format function must make assumptions about how to fill in the remaining characters.

For example, suppose that you want to format the string &quot;Microsoft&quot;, so you make the following call to the Format function: Format(&quot;Microsoft&quot;,&quot;@-@&quot;) Because you have not supplied enough at signs (@), the Format function must decide from which end it must start to fill in the remaining characters. The output differs depending on which end the function starts, which differs between Visual Basic versions 5.0 and 6.0.



RESOLUTION
To resolve this problem, always supply the correct number of placeholder characters. If you use the preceding example, change the call to the Format function as follows: Format(&quot;Microsoft&quot;,&quot;@-@@@@@@@@&quot;)



MORE INFORMATION
Suppose that you make the following call to the Format function: Format(&quot;Microsoft&quot;,&quot;@-@&quot;) In Visual Basic 5.0, the placeholders are filled in from right to left, and the following output is returned:

Microsoft-t However, this behavior changes in Visual Basic 6.0. In Visual Basic 6.0, the placeholders are filled in from left to right. As a result, the following output is returned: M-icrosoft

Additional query words: vba

Keywords: kbstring kbprb kbpending KB297882

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.