Part:1 "How to Load data from a text file (RTF) to Richtextbox using Common Dialog Control and Richtextbox Control in Visual Basic"
and How to Clear Rich Text Box Control.
Link : https://youtu.be/32ITifBWJUI
Part:2 How to Save Richtextbox data to a file using Common dialog control in Visual basic
Link : https://youtu.be/oBJE3j2JJ1w
Part :3 How to Print Richtextbox content in visual basic and Print to a PDF file in visual basic .
Step by Step Tutorial
No step is skipped
Code:
Dim data As String
Dim filename As String
Private Sub clearbtn_Click()
RichTextBox1.Text = ""
End Sub
Private Sub loadbtn_Click()
opendialog.Filter = "Text Files (*.txt)|*.txt|RTf Files (*.rtf)|*.rtf|"
opendialog.ShowOpen
data = opendialog.filename
RichTextBox1.LoadFile (data)
End Sub
Private Sub printbtn_Click()
opendialog.CancelError = True
On Error GoTo CancelAlert
opendialog.Flags = cdlPDReturnDC + cdlPDNoPageNums
opendialog.ShowPrinter
RichTextBox1.SelPrint opendialog.hDC
Printer.EndDoc
CancelAlert:
Exit Sub
End Sub
Private Sub savebtn_Click()
opendialog.Filter = "Text Files (*.txt)|*.txt|RTf Files (*.rtf)|*.rtf|"
opendialog.ShowSave
filename = opendialog.filename
RichTextBox1.SaveFile filename, rtfText
End Sub