Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7666791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:55:33+00:00 2026-05-31T14:55:33+00:00

Good day, I have been searching for a way to format output using writeline/write

  • 0

Good day,

I have been searching for a way to format output using writeline/write (streamwriter)
using RTF tags and wondering if there is a syntax for this, if it exists. I have not
been able to find a resource which clearly explains how to “pretty” up output sent to a
file.

The reason why I am asking is because I want to “print” results from my program into
a file that, at the very least, would be centered, tabbed and even bolded where possible
without requiring the user to go and futz with it. I think I saw that Crystal Reports
won’t work with VB 2010 Express and, quite frankly, just want to create a file with
output.

The problem I am having is how I can make output look less like writeline did it
(you know, writeliney-ish) and more like someone took the time to make writeline
look like it did something awesome.

Here’s some code to show you what I’m trying to do:

sw.Write("                    RATE QUOTATION ")
            sw.WriteLine("   ")
            sw.WriteLine("           ")
            sw.WriteLine(mycompanyname)
            sw.WriteLine(mycompanyaddress1 + ControlChars.Tab + "Phone:", companyphone)
            sw.WriteLine(mycompanyaddress3 + ControlChars.Tab + "Fax:", companyfax)
            sw.WriteLine(cityname, stateprovince, zippostal)
            sw.WriteLine("Visit us online at:", websiteaddress)
            sw.WriteLine("    ")
            sw.WriteLine("Quoted by:", contactname + " " + "E-mail:", contactemail)
            sw.Write("Date: ")
            sw.WriteLine(DateTime.Now)
            sw.WriteLine(" ")
            sw.WriteLine(("Customer Name:" + "   " + quotename.Text), "Company:" + "   " + quotecompany.Text + " " + "Customer E-mail:" + "   " + quoteemail.Text)
            sw.WriteLine(("Phone:" + "   " + quotephone.Text + ControlChars.Tab + "Fax:" + "   " + quotefax.Text))
            sw.WriteLine("  ")
            sw.WriteLine("Shipment Details:")

Is there a way to control writeline in such a way that you can create an RTF via streamwriter and specify formatting tags, like centering and bold, etc? I’m trying to think of a way so that the RTF header information is created when streamwriter starts it’s business and prints what I want out. I don’t think there’s an elegant way to create a PDF either so I’m kind of opting for old school output for now.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:55:34+00:00Added an answer on May 31, 2026 at 2:55 pm

    As promised, started playing with some code and thought I’d share it, although I’m still trying to figure out why vbNewLine doesn’t work. :/

    Originally, I was trying to use streamwriter to embed RTF codes, like (\rtf1) and (\b) etc..but these do not work within writeline statements that I tried, such as:

    writeline(“\b This is in bold \b0”)

    So by pretending to have a richtext box (rtb), you can create a file that will allow font formatting and other text formatting (albeit still trying to figure out a few things lol),
    which may be an alternative to streamwriter if you care about how output appears in a file.

    Public Class Form1

    Private Property richtextbox1 As Object
    
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim something As String
        Dim somethingelse As String
        Dim butwaittheresstillmore As String
    
        something = TextBox1.Text
        somethingelse = TextBox2.Text
        butwaittheresstillmore = TextBox3.Text
    
        Save1.InitialDirectory = "c:\users\shawn\desktop"
        Save1.FileName = " "
        Save1.Filter = " RTF file | *.rtf"
        Save1.ShowDialog()
    
    
        Dim rtb As New RichTextBox
        rtb.SelectionAlignment = HorizontalAlignment.Center
        rtb.Text = something & vbNewLine
    
        rtb.SelectionAlignment = HorizontalAlignment.Left
        rtb.Text = somethingelse + (" another field: ") + butwaittheresstillmore
        rtb.SelectAll()
        rtb.SelectionFont = New Font(New FontFamily("Arial"), 12, FontStyle.Regular,
        GraphicsUnit.Pixel)
        rtb.SaveFile(Save1.FileName)
    End Sub
    

    End Class

    I wanted to control the font and alignment and this seems to do the trick, although I’m trying to sort out using “tab” position and line feeds. I see that I can align left, center and right. Anyway, I hope this helps someone who might otherwise want a quick way to make a document where they can control the font.

    Thanks!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been searching around the web all day for the best way to
Good day, I have been using JNA for a while to interact with the
Good Day, I have been trying various methods both found on here and in
hope you're having a good day. I have been programming a IRC chatbot in
Good day, I have been given an assignment that gets data off a CSV
Good day, I have a problem in a .NET page where I am using
Good day. I have little usage of Flash CS4, however i have to build
Good day, If I have for example the documents which have the following fields
Good day, I have the following problem: class B extends class A and methods
Good day! I right now have a function the drags an element from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.