0

生成表单时,我的代码如下所示:

Set obj = Me.DataSetAuthor.Controls.Add("Forms.Label.1", fld)
With obj
    .top = top
    .Left = 5000
    .Width = 20
    .height = 18
    .ControlTipText = "search " & heading
    .caption = "U"
    .FontName = "Wingdings 2"
    .Font.name = "Wingdings 2"
    .Font.Size = 16
End With

在我的静态编辑器版本中,字体名称为“Wingdings 2”的标题“U”给了我一个里面有“X”的小圆圈。但不是在这里,我得到字体大小为 16 的“U”。我需要做什么才能获得 Wingdings 2 字体?

4

1 回答 1

1

您应该首先设置字体名称,然后才设置标题:

Private Sub UserForm_Initialize()
  Dim obj As MSForms.Label, top As Double, Heading As String
  top = Me.top: Heading = "My header"
   Set obj = Me.Controls.Add("Forms.Label.1", "myLab1")
   With obj
       .top = top
        .Left = 50 'for 5000 it may go out from the form...
        .Width = 20
        .Height = 18
        .ControlTipText = "search " & Heading
        .Font.Name = "Wingdings 2"
        .Caption = "U"
        .Font.Size = 16
   End With
End Sub
于 2021-10-16T14:54:18.103 回答