LoadFile Method Example

This example displays a dialog box to choose an .rtf file, then loads that file into a RichTextBox control. To try this example, put a RichTextBox control, a CommandButton control, and a CommonDialog control on a form. Paste this code into the General Declarations section of the form. Then run the example.

Private Sub Command1_Click()
   CommonDialog1.Filter = "Rich Text Format files|*.rtf"
   CommonDialog1.ShowOpen
   RichTextBox1.LoadFile CommonDialog1.Filename, rtfRTF
End Sub