How to Create RTF Files With VB.Net

Written by jim campbell
  • Share
  • Tweet
  • Share
  • Email

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:


  1. 1

    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.

  2. 2

    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.

  3. 3

    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")

  4. 4

    Add text to the file. The following creates a basic RTF file:


    write.WriteLine("Basic Text")

    write.WriteLine ("}")

    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.

  5. 5

    After you finish writing to the file, you must close it. Add the final line of code to close the file:


Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.