在打印或預(yù)覽報(bào)表時(shí),或者將報(bào)表輸出保存為文件時(shí),如果使用 Circle、Line、Pset 或 Print 方法,則可以使用 ScaleLeft 屬性來(lái)指定說(shuō)明頁(yè)面左邊緣位置的水平坐標(biāo)單位數(shù)。Single 型,可讀寫(xiě)。
expression 必需。返回“應(yīng)用于”列表中的一個(gè)對(duì)象的表達(dá)式。
可以使用由節(jié)的 OnPrint 屬性設(shè)置指定的宏或 Visual Basic 事件過(guò)程來(lái)設(shè)置 ScaleLeft 屬性。
通過(guò)使用這些屬性和相關(guān)的 ScaleHeight 和 ScaleWidth 屬性,可以建立一個(gè)有正、負(fù)坐標(biāo)值的自定義坐標(biāo)系統(tǒng)。共有四個(gè)這樣的“刻度”屬性,它們采用以下方法與 ScaleMode 屬性交互作用:
? | 只要為任何其他“刻度”屬性設(shè)置了值,ScaleMode 屬性就自動(dòng)設(shè)為 0。 |
? | 只要 ScaleMode 屬性的設(shè)置大于 0, ScaleHeight 和 ScaleWidth 屬性就會(huì)改為新的測(cè)量單位,并且 ScaleLeft 和 ScaleTop 屬性會(huì)跟著設(shè)為 0。同時(shí),CurrentX 和 CurrentY 屬性設(shè)置也會(huì)更改,以反映當(dāng)前點(diǎn)的新坐標(biāo)。 |
另外,也可以在一個(gè)語(yǔ)句中使用 Scale 方法對(duì) ScaleHeight、ScaleWidth、ScaleLeft 和 ScaleTop 屬性進(jìn)行設(shè)置。
以下示例使用 Circle 方法來(lái)繪制圓,并在圓中創(chuàng)建扇形,然后使用 FillColor 和 FillStyle 屬性將扇形顏色設(shè)為紅色。另外還在左上方到圓心之間畫(huà)了一條直線。
若要在 Microsoft Access 中試用該示例,請(qǐng)先創(chuàng)建一個(gè)新的報(bào)表。將“主體”節(jié)的 OnPrint 屬性設(shè)為 [事件過(guò)程]。在報(bào)表的模塊中輸入下列代碼,然后切換到“打印預(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