Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In Visual Basic 6.0, the ScaleMode property could be used to change the coordinate system for a form or PictureBox control from the default scale of twips.
Visual Basic 2008 does not support multiple coordinate systems; only pixels are supported. During upgrade, coordinates are automatically converted from twips to pixels; code that sets the ScaleMode property at run time will cause a compilation error and must be modified.
Note
The upgrade tool assumes that the design-time setting for the ScaleMode property was twips; if this is not the case, the conversion will be incorrect and must be fixed.
What to do next
Remove the line of code that sets the ScaleMode property.
Review any code that was based on the ScaleMode property and modify any calculations as necessary. For example, the following code shows how to modify a procedure that used a ScaleMode of inches.
' Visual Basic 6.0 Form1.ScaleMode = vbInches Text1.Move 2, 1
The above procedure moves the text box 2 inches right and 1 inch down from the upper left corner of the form.
' After upgrade to Visual Basic 2008 'UPGRADE ISSUE: Constant vbInches was not upgraded. 'UPGRADE ISSUE: Form property Form1.ScaleMode is not supported. ' The next line must be removed in order to compile. Form1.ScaleMode = vbInches ' Twips are converted to pixels, but the original inch values are used. Text1.SetBounds(VB6.TwipsToPixelsX(2), VB6.TwipsToPixelsX(1),...
After upgrade, the procedure moves the text box right by 2 pixels and down by 1 pixel — not the desired result.
' Modified Visual Basic 2008 code ' Removed the ScaleMode line. ' Convert the scale (1 inch = 1440 twips). Text1.SetBounds(VB6.TwipsToPixelsX(2880), VB6.TwipsToPixelsX(1440),...
By multiplying the inches by 1440, the twips to pixel conversion now gives the same result as in the original Visual Basic 6.0 code.