16,554
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command1_Click()
RichTextBox1.TextRTF = CutLine(RichTextBox1.TextRTF, 10)
End Sub
Private Function CutLine(Rtf As String, CountValue As Long) As String
Dim Head As String, newRtf As String
Dim strLine() As String
Dim i As Long, MaxLine As Long
strLine = Split(Rtf, "\par ")
MaxLine = UBound(strLine)
If MaxLine <= CountValue Then
CutLine = Rtf
Exit Function
End If
Head = Left(strLine(0), InStr(strLine(0), "\fs18 ") + 5)
newRtf = "\par }"
For i = MaxLine To MaxLine - CountValue - 1 Step -1
newRtf = vbCrLf & "\par " & strLine(i) & newRtf
Next
newRtf = Head & newRtf
CutLine = newRtf
End Function