The rich text format (RTF) provides you with a standardised method to customise fonts and colours for a text document. RTF is used to transfer files to different applications without losing the bold, italicised, underlined and colour fonts. You output to an RTF file using the RTF notation at the top and end of the file output from VB.NET.
- Skill level:
Other People Are Reading
Click the Windows "Start" button, and select "All Programs." Click "Microsoft .NET," then click the "Visual Studio" shortcut to open the VB.NET programming software.
Double-click the VB.NET project name to load the code in the software. Right-click the form you want to use to write to the file in "Solution Explorer" to open the code editor.
You must create the file before you can write to it. The following code creates a file stream variable to create the file and open it:
Dim file as System.IO.File
Dim write as System.IO.StreamWriter
write = file.CreateText("C:\rtf_file.rtf")
Add text to the file. The following creates a basic RTF file:
The first line of code indicates that the file is an RTF. You can place any text after this line of text. The final line of code closes the RTF format stream.
After you finish writing to the file, you must close it. Add the final line of code to close the file:
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for