Private Sub Form_Load()
Dim file_name As String Dim i As Integer Dim txt As String Dim pos1 As Integer Dim pos2 As Integer ' Load the file. file_name = App.Path If Right$(file_name, 1) <> "\" Then file_name = file_name & "\" file_name = file_name & "books.rtf" rchWholeFile.LoadFile file_name ' Break the file into paragraphs. txt = rchWholeFile.Text pos1 = 0 For i = 0 To rchParagraph.UBound pos2 = InStr(pos1 + 1, txt, vbCrLf) If pos2 = 0 Then pos2 = Len(txt) rchWholeFile.SelStart = pos1 rchWholeFile.SelLength = pos2 - pos1 rchParagraph(i).SelStart = 0 rchParagraph(i).SelLength = Len(rchParagraph(i).Text) rchParagraph(i).SelRTF = rchWholeFile.SelRTF rchParagraph(i).SelStart = 0 rchParagraph(i).SelLength = 0 pos1 = pos2 + 1 Next i End Sub |