调试时先试一下你的文本框的一行放多少个字符正好满,假设是10个字符然后 text1.multiline = true 设置一个判断变量 dim IsFull as Boolean IsFull = false 设置一个每行的字符数统计量 dim CNum as integer CNum = len(text1.text) 设置变量保存处始text的高度 dim FirstHeight as integer FirstHeight = text1.height '''以下是实现代码 private sub text1_change() if len(text1.text) - Cnum > 9 then text1.height = text1.height + FirstHeight Cnum = len(text1.text) end if end sub 随手写的,仅供参考
设置一个判断变量 dim IsFull as Boolean
IsFull = false
设置一个每行的字符数统计量 dim CNum as integer
CNum = len(text1.text)
设置变量保存处始text的高度 dim FirstHeight as integer
FirstHeight = text1.height
'''以下是实现代码
private sub text1_change()
if len(text1.text) - Cnum > 9 then
text1.height = text1.height + FirstHeight
Cnum = len(text1.text)
end if
end sub
随手写的,仅供参考
text1.text="asdf"+chr(13)+"asdfjk"
执行后,文本框就自动显示为只能显示两行四列的大小。
Me.ScaleMode = 3
With Text1
.Text = "asdf" + vbCrLf + "asdfjk"
.Width = 6 + (IIf(LenB("asdf") > LenB("asdfjk"), Me.TextWidth("asdf"), Me.TextWidth("asdfjk")))
.Height = Me.TextHeight("asdfjk") * 2 + 6
End With
End Sub