Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
XML RSS Feed
VB6 Scale Method Bug
The Scale method takes as parameters the coordinates of two opposite corners of a region. It sets a PictureBox's Scale properties so they match that region. For example, this code:
    ctl.Scale (x1, y1)-(x2, y2)
sets the control's Scale properties to these values:

PropertyValue
ctl.ScaleLeftx1
ctl.ScaleWidthx2 - x1
ctl.ScaleTopy1
ctl.ScaleHeighty2 - y1

Unfortunately in Visual Basic 6, the Scale method checks its arguments to ensure that x1 < x2 and y1 < y2. Quite often it is convenient to specify y1 > y2 to make the control's coordinate system have increasing Y values from bottom-to-top instead of the usual top-to-bottom difection. In Visual Basic 6, the Scale method switches the arguments if necessary to make the coordinates keep their usual orientation. Programs that use this technique correctly in Visual Basic 5 and earlier, draw things upside down in Visual Basic 6.

This is a classic type of bug introduced into a later version of a product. It seems to make sense to some developer, but customers have been relying on the product's current behavior. "Fixing" the product breaks the customers' programs.

The way to fix this is to set the Scale property values explicitly instead of using the Scale method.

    ctl.ScaleLeft = x1
    ctl.ScaleWidth = x2 - x1
    ctl.ScaleTop = y1
    ctl.ScaleHeight = y2 - y1

 
Subscribe to the VB Helper newsletter
Copyright © 1997-2001 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
www.vb-helper.com/highclr.htm Updated