如何在 dynamically-generated 文本框中获得不同的字体?

How do I get different fonts in dynamically-generated text boxes?

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

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 字体?

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

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