|
我修改了一下请老汉指正
‘=======================
Function ctlFontSize(ctl As Control)
Dim w As Single, c As Single, d As Single
Dim i As Long
Dim b As Boolean
ctl.FontSize = Nz(n) '1 磅等于1/72 英寸
'1440 缇等于一英寸
w = ctl.Width / 1440
For i = n To 1 Step -1
'使用vbFromUnicode判断中文字符有几个
'注意unicode编码的字串(如中文、日文、韩文等)
c = LenB(StrConv(Nz(ctl.Value, ""), vbFromUnicode)) - Len(Nz(ctl.Value, ""))
d = Len(Nz(ctl.Value, "")) - c
b = ((2 * c + d + 1) * i) / (2 * 72) - w <= 0
'b = ((Len(ctl.Value) + 1) * i) / (2 * 72) - w <= 0
If b = True Then
ctl.FontSize = i
Exit For
End If
Next
End Function |
评分
-
查看全部评分
|