TextBox.FontSize 属性 (Access)
在以下情况下,使用 FontSize 属性指定文本的点大小:
- 在显示或打印窗体和报表上的控件时。
- 当报表上使用 Print 方法。
Integer 型,可读/写。
语法
表达式。FontSize
表达 一个代表 TextBox 对象的变量。
备注
FontSize 属性使用以下设置。
Setting | 说明 |
---|---|
8 | (除命令按钮之外的所有报表及控件的默认值)文本字号为 8 磅。 |
10 | (命令按钮的默认值)文本字号为 10 磅。 |
其他字号 | 文本以指定字号显示。 |
可以使用控件的默认控件样式或 Visual Basic 中的 DefaultControl 属性设置此属性的默认值。
对于报表,您可以仅在事件过程中或在 OnPrint 事件属性设置所指定的宏中设置该属性。
在 Visual Basic 的 FontSize 属性设置使用所需的字体大小等于的数值表达式。 FontSize 属性的设置可以是 1 到 127,含之间。
示例
下面的示例使用 Print 方法在 report1 的报表上显示文本。 它使用 TextWidth 和 TextHeight 方法来使文本居中垂直和水平。
Private Sub Detail_Format(Cancel As Integer, _
FormatCount As Integer)
Dim rpt as Report
Dim strMessage As String
Dim intHorSize As Integer, intVerSize As Integer
Set rpt = Me
strMessage = "DisplayMessage"
With rpt
'Set scale to pixels, and set FontName and
'FontSize properties.
.ScaleMode = 3
.FontName = "Courier"
.FontSize = 24
End With
' Horizontal width.
intHorSize = Rpt.TextWidth(strMessage)
' Vertical height.
intVerSize = Rpt.TextHeight(strMessage)
' Calculate location of text to be displayed.
Rpt.CurrentX = (Rpt.ScaleWidth/2) - (intHorSize/2)
Rpt.CurrentY = (Rpt.ScaleHeight/2) - (intVerSize/2)
' Print text on Report object.
Rpt.Print strMessage
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。