Insert these 2 procedires in your code.
Now to determine the number of lines in the rich text box, u could call it like thisCode:Public Function NumberOfLines(TextBox As RichTextBox) As Integer Dim sLines() As String sLines() = Split(TextBox.Text, vbCrLf) NumberOfLines = UBound(sLines) + 1 End Function Public Function CurrentLine(TextBox As RichTextBox) As Integer Dim sCopy As String Dim sLines() As String Dim intCon As Integer sCopy = TextBox.Text sCopy = Mid(sCopy, 1, TextBox.SelStart) & "{VBROCKS}" & Mid(sCopy, TextBox.SelStart + 1) sLines() = Split(sCopy, vbCrLf) For intCon = 0 To UBound(sLines()) If InStr(1, sLines(intCon), "{VBROCKS}") Then CurrentLine = intCon + 1 Exit For End If Next End Function
To determine the current lineCode:Msgbox NumberOfLines(MyRTFBox)
Code:Msgbox CurrentLine(MyRTFBox)




Reply With Quote