在打印或預(yù)覽報表時,或者將報表的輸出保存為文件時,如果使用 Circle、Line、Pset 或 Print 方法,則可以使用 ScaleTop 屬性來指定說明頁面上邊緣位置的垂直坐標(biāo)單位數(shù)。Single 型,可讀寫。
expression 必需。返回“應(yīng)用于”列表中的一個對象的表達(dá)式。
可以使用由節(jié)的 OnPrint 屬性設(shè)置指定的宏或 Visual Basic 事件過程來設(shè)置 ScaleTop 屬性。
通過使用這些屬性和相關(guān)的 ScaleHeight 和 ScaleWidth 屬性,可以建立一個有正、負(fù)坐標(biāo)值的自定義坐標(biāo)系統(tǒng)。共有四個這樣的“刻度”屬性,它們采用以下方法與 ScaleMode 屬性交互作用:
? | 只要為任何其他“刻度”屬性設(shè)置了值,ScaleMode 屬性就自動設(shè)為 0。 |
? | 只要 ScaleMode 屬性的設(shè)置大于 0,ScaleHeight 和 ScaleWidth 屬性就會改為新的測量單位,并且 ScaleLeft 和 ScaleTop 屬性會跟著設(shè)為 0。同時,CurrentX 和 CurrentY屬性設(shè)置也會更改,以反映當(dāng)前點(diǎn)的新坐標(biāo)。 |
另外,也可以在一個語句中使用 Scale 方法對 ScaleHeight、ScaleWidth、ScaleLeft 和 ScaleTop 屬性進(jìn)行設(shè)置。
以下示例使用 Circle 方法來繪制圓,并在圓中創(chuàng)建扇形,然后使用 FillColor 和 FillStyle 屬性將扇形顏色設(shè)為紅色,另外還在左上方到圓心之間畫了一條直線。
若要在 Microsoft Access 中試用這一示例,請先創(chuàng)建一個新的報表。將“主體”節(jié)的 OnPrint 屬性設(shè)置為 [事件過程]。在報表的模塊中輸入下列代碼,然后切換到“打印預(yù)覽”。
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Const conPI = 3.14159265359
Dim sngHCtr As Single
Dim sngVCtr As Single
Dim sngRadius As Single
Dim sngStart As Single
Dim sngEnd As Single
sngHCtr = Me.ScaleWidth / 2 ' Horizontal center.
sngVCtr = Me.ScaleHeight / 2 ' Vertical center.
sngRadius = Me.ScaleHeight / 3 ' Circle radius.
Me.Circle (sngHCtr, sngVCtr), sngRadius ' Draw circle.
sngStart = -0.00000001 ' Start of pie slice.
sngEnd = -2 * conPI / 3 ' End of pie slice.
Me.FillColor = RGB(255, 0, 0) ' Color pie slice red.
Me.FillStyle = 0 ' Fill pie slice.
' Draw Pie slice within circle
Me.Circle (sngHCtr, sngVCtr), sngRadius, , sngStart, sngEnd
' Draw line to center of circle.
Dim intColor As Integer
Dim sngTop As Single, sngLeft As Single
Dim sngWidth As Single, sngHeight As Single
Me.ScaleMode = 3 ' Set scale to pixels.
sngTop = Me.ScaleTop ' Top inside edge.
sngLeft = Me.ScaleLeft ' Left inside edge.
sngWidth = Me.ScaleWidth / 2 ' Width inside edge.
sngHeight = Me.ScaleHeight / 2 ' Height inside edge.
intColor = RGB(255, 0, 0) ' Make color red.
' Draw line.
Me.Line (sngTop, sngLeft)-(sngWidth, sngHeight), intColor
End Sub