Scale Method

See Also12K2P3E              ExampleC24BQ3>Low

Defines the coordinate system for an object.

Syntax

[object.]Scale [(x1, y1) - (x2, y2)]

Remarks

The Scale method has these parts:

Part               Description

 

object            Object (non-MDI form, picture box, or Printer object) to which the coordinate system is applied.

x1, y1            Single-precision values for the horizontal and vertical coordinates that define the upper-left corner of the object.

x2, y2            Single-precision values for the horizontal and vertical coordinates that define the lower-right corner of the object.

 

The Scale method allows you to reset the coordinate system to any scale you choose. Scale with no arguments resets the coordinate system to twips2SWJ8D3. Scale affects the coordinate system for the both the run-time graphics statements and the placement of controls.


See Also

ScaleHeight Property3J8U7ZN

ScaleLeft Property138Z3ME

ScaleMode Property5SNY0BP

ScaleTop Property138Z3ME

ScaleWidth Property3J8U7ZN


Scale Method Example

The example uses the Scale method to set up a custom coordinate system so that a bar chart can be drawn on a form. To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

 

Sub Form_Click ()

   Dim I, OldFontSize                    ' Declare variables

   Width = 8640: Height = 5760           ' Set form size in twips.

   Move 100,100                          ' Move form origin.

   AutoRedraw = -1                       ' Turn on AutoRedraw.

   OldFontSize = FontSize                ' Save old font size.

   BackColor = QBColor(7)                ' Set background to gray.

   Scale (0, 110)-(130, 0)               ' Set custom coordinate system.

   For I = 100 To 10 Step -10

      Line (0, I)-(2, I)                 ' Draw scale marks every 10 units.

      CurrentY = CurrentY + 1.5          ' Move cursor position.

      Print I                            ' Print scale mark value on left.

      Line (ScaleWidth - 2, I)-(ScaleWidth, I)

      CurrentY = CurrentY + 1.5          ' Move cursor position.

      CurrentX = ScaleWidth - 9

      Print I                            ' Print scale mark value on right.

   Next I

   ' Draw bar chart

   Line (10, 0)-(20, 45), RGB(0, 0, 255), BF   ' 1st blue bar.

   Line (20, 0)-(30, 55), RGB(255, 0, 0), BF   ' 1st red bar.

   Line (40, 0)-(50, 40), RGB(0, 0, 255), BF

   Line (50, 0)-(60, 25), RGB(255, 0, 0), BF

   Line (70, 0)-(80, 35), RGB(0, 0, 255), BF

   Line (80, 0)-(90, 60), RGB(255, 0, 0), BF

   Line (100, 0)-(110, 75), RGB(0, 0, 255), BF

   Line (110, 0)-(120, 90), RGB(255, 0, 0), BF

   CurrentX = 18: CurrentY = 100         ' Move cursor position.

   FontSize = 14                         ' Enlarge font for title.

   Print "Widget Quarterly Sales"        ' Print title.

   FontSize = OldFontSize                ' Restore font size.

   CurrentX = 27: CurrentY = 93          ' Move cursor position.

   Print "Planned Vs Actual"             ' Print subtitle.

   Line (29, 86)-(34, 88), RGB(0, 0, 255), BF  ' Print legend.

   Line (43, 86)-(49, 88), RGB(255, 0, 0), BF

End Sub