PictureAlignment 属性示例
以下示例使用 PictureAlignment 属性设置背景图片。 此示例还标识由 PictureAlignment 提供的对齐方式选项。
若要使用此示例,请将此示例代码复制到窗体的声明部分。 确保该窗体包含:
- 名为 Frame1 的 Frame 。
- 一个名为"SpinButton1"的 SpinButton 。
- 一个名为"TextBox1"的 TextBox 。
Dim Alignments(5) As String
Private Sub UserForm_Initialize()
Alignments(0) = "0 - Top Left"
Alignments(1) = "1 - Top Right"
Alignments(2) = "2 - Center"
Alignments(3) = "3 - Bottom Left"
Alignments(4) = "4 - Bottom Right"
'Specify a bitmap that exists on your system
Frame1.Picture = LoadPicture("c:\winnt2\ball.bmp")
SpinButton1.Min = 0
SpinButton1.Max = 4
SpinButton1.Value = 0
TextBox1.Text = Alignments(0)
Frame1.PictureAlignment = SpinButton1.Value
End Sub
Private Sub SpinButton1_Change()
TextBox1.Text = Alignments(SpinButton1.Value)
Frame1.PictureAlignment = SpinButton1.Value
End Sub
Private Sub TextBox1_Change()
Select Case TextBox1.Text
Case "0"
TextBox1.Text = Alignments(0)
Frame1.PictureAlignment = 0
Case "1"
TextBox1.Text = Alignments(1)
Frame1.PictureAlignment = 1
Case "2"
TextBox1.Text = Alignments(2)
Frame1.PictureAlignment = 2
Case "3"
TextBox1.Text = Alignments(3)
Frame1.PictureAlignment = 3
Case "4"
TextBox1.Text = Alignments(4)
Frame1.PictureAlignment = 4
Case Else
TextBox1.Text = Alignments(SpinButton1.Value)
Frame1.PictureAlignment = SpinButton1.Value
End Select
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。