📄 28.txt
字号:
Measuring a text extent
It注释:s very simple to determine the extent of a string in VB. You can do so with WinAPI functions, but there注释:s an easier way: Use the AutoSize property of a Label component. First, insert a label on a form (labMeasure) and set its AutoSize property to True and Visible property to False. Then write this simple routine:
Private Function TextExtent(txt as String) as Integer
labMeasure.Caption = txt
TextExtent = labMeasure.Width
End Function When you want to find out the extent of some text, simply call this function with the string as a parameter.
In my case it turned out that the measure was too short. I just added some blanks to the string. For example:
Private Function TextExtent(txt As String) As Integer
labMeasure.Caption = " " & txt
TextExtent = labMeasure.Width
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -