FIX: Overflow Error If Print Long String to Form or Printer

Last reviewed: October 30, 1997
Article ID: Q74517
1.00 2.00 WINDOWS kbprg kbbuglist

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, version 2.0
- Microsoft Visual Basic programming system for Windows, version 1.0

SYMPTOMS

An "Overflow" error message may occur when you print a long string in Microsoft Visual Basic for Windows.

When a character is printed using the Print method, the CurrentX and CurrentY coordinates are also updated for the object being printed to. If the string being printed is long enough to cause the value of the CurrentX property to exceed 32,767 twips, an "Overflow" error will occur. This behavior is by design.

"Overflow" can be caused by printing a single long string or by repeatedly printing shorter strings that are appended onto the end of the last string -- using the Visual Basic semicolon (;) operator.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Visual Basic versions 1.0 and 2.0 for Windows. This problem was corrected in Microsoft Visual Basic version 3.0 for Windows.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start Visual Basic or choose New Project from the File menu.

  2. Place a label control on Form1.

  3. Add the following code to the Form_Click event:

            Sub Form_Click()
                For index% = 1 to 1000
                    Print "A";
                    Label1.Caption = Str$(CurrentX)
                Next
            End Sub
    
    

  4. From the Run menu, choose Start.

  5. Click Form1.

An "Overflow" error will occur. You can examine the label caption to see that the value of Form1.CurrentX plus the TextWidth of "A" exceeded 32767 at the time of the error.


Additional reference words: buglist1.00 buglist2.00 fixlist3.00 1.00 2.00
3.00
KBCategory: kbprg kbbuglist
KBSubcategory: PrgCtrlsStd
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.