vb 怎么删除文本框最后一行空行?

来源:百度知道 编辑:UC知道 时间:2024/06/22 21:22:47
vb 怎么删除文本框最后一行空行?
嗯,举个例子:
文本框内容如下:
text1
text2

text3
text4

text5
text6
-----这个最后一行是空的,想删除它.

建Text1, 改Multiline=True,再建Command1.
代码如下。
==================
Private Sub Command1_Click()
If Right(Text1.Text, 2) = vbCrLf Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End Sub

啥?什么意思?

Private Sub Command1_Click()
temp = Split(Text1.Text, vbCrLf)
Text1.Text = ""
For i = 0 To UBound(temp) - 1
If temp(i) <> "" Then Text1.Text = Text1.Text & temp(i) & vbCrLf
Next
End Sub