|
发表于 2021-3-11 21:45:01
|
显示全部楼层
如果你的回车都是硬回车,可以考虑使用正则表达式对象简化操作。
我编的程序的目的是删除空行以及含有空格的空行:
Private Sub Command1_Click()
Dim temp As String, s() As String, i As Long
temp = RichTextBox1.Text
s = Split(temp, vbCrLf)
For i = 0 To UBound(s)
If Len(Trim(s(i))) = 0 Then s(i) = ""
Next
temp = Join(s, vbCrLf)
While InStr(temp, vbCrLf & vbCrLf) > 0
temp = Replace(temp, vbCrLf & vbCrLf, vbCrLf)
Wend
RichTextBox1.Text = temp
End Sub |
|