Visual Basic: RichTextBox Control

Visual Studio 6.0

SaveFile Method

See Also    Example    Applies To

Saves the contents of a RichTextBox control to a file.

Syntax

object.SaveFile(pathname, filetype)

The SaveFile method syntax has these parts:

Part Description
object Required. An object expression that evaluates to an object in the Applies To list.
pathname Required. A string expression defining the path and filename of the file to receive the contents of the control.
filetype Optional. An integer or constant that specifies the type of file loaded, as described in Settings.

Settings

The settings for filetype are:

Constant Value Description
rtfRTF 0 (Default) RTF. The RichTextBox control saves its contents as an .rtf file.
rtfText 1 Text. The RichTextBox control saves its contents as a text file.

Remarks

You can also use the Write function in Visual Basic and the TextRTF and SelRTF properties of the RichTextBox control to write .rtf files. For example, you can save the highlighted contents of a RichTextBox control to an .rtf file as follows:

Open "mytext.rtf" For Output As 1

Print #1, RichTextBox1.SelRTF
Show: