FIX: Overflow Error When CurrentX Or CurrentY Greater Than 32K (100190)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition for Windows 2.0
- Microsoft Visual Basic Standard Edition for Windows 3.0
This article was previously published under Q100190 SYMPTOMS
An Overflow error results if you attempt to set CurrentX or CurrentY
to a value greater than 32,767 while the current ScaleMode is set to
Twips. When using another ScaleMode such as pixels, the same problem
occurs if the conversion of the CurrentX or CurrentY value to twips
is greater than 32,767.
However, when you use the Print method (or other graphics method) you
can correctly cause the value of CurrentX or CurrentY to exceed 32,767
when the ScaleMode is set to twips.
CAUSE
When CurrentX or CurrentY is set explicitly, Visual Basic incorrectly
converts the value using the current scale mode to twips. If the result
of the conversion to twips is greater the 32,767, an Overflow error
occurs. For example, if the ScaleMode is set to Pixels, CurrentX and
CurrentY cannot exceed approximately 2731 pixels if the twips per pixel
ratio is 12 because 12 times 2731 is 32,772 which is greater than 32767.
When setting CurrentX or CurrentY, Visual Basic should convert the
value using the current ScaleMode to pixels rather than twips before
comparing the result to 32,767. As a result of this bug, CurrentX and
CurrentY are each restricted to a limit 12-14 times smaller (depending on
TwipsPerPixelX or TwipsPerPixelY) than they should be.
WORKAROUND
To work around the problem, call the Windows API functions: - Call TextOut to control the position of text in a picture box or a form.
- Call MoveTo and LineTo to control the position of a line.
- Call other appropriate Windows API functions to position the output for
other graphics methods such as the circle method.
An example is shown in the MORE INFORMATION section below.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This problem has been fixed in Visual
Basic version 4.0.
Modification Type: | Major | Last Reviewed: | 10/29/2003 |
---|
Keywords: | kbbug kbfix KB100190 |
---|
|