Label控件没有提供textwidth函数,想使用textwidth可用一个picturebox作为载体:
Private Sub Command1_Click()
Dim temppic As PictureBox
Set temppic = Controls.Add("vb.picturebox", "temppic")
temppic.Font = Me.Label1.Font
Dim i As Long
Dim s As String
s = "123456abcqqqqqqqqq"
i = temppic.TextWidth(s)
Me.Label1.Caption = s
Me.Label1.Width = i
Controls.Remove temppic
End Sub