After looking on the internet i have found some code for printing the text of a richtextbox. I added comments and added a few things...

Commented Code:

vb.net Code:
  1. 'NOTE * // = opening comments and \\ = closing comments...
  2.  
  3. Public Class Form1
  4.     'Declares public variables...
  5.     Public printer As String
  6.     Public copies As Integer
  7.     Private Sub cmdPrint_Click(ByVal sender As System.Object, _
  8.     ByVal e As System.EventArgs) Handles cmdPrint.Click
  9.         Dim Print As New myPrinter 'Declares Print as a new myPrinter class.
  10.         Dim myprintdialog As New PrintDialog 'Creates Print Dialog.
  11.         With myprintdialog
  12.             If .ShowDialog = Windows.Forms.DialogResult.OK Then
  13.                 '//------
  14.                 printer = .PrinterSettings.PrinterName 'Sets variable printer to selected
  15.                 'printers name.
  16.                 '\\------
  17.                 '//------
  18.                 copies = .PrinterSettings.Copies 'Sets ammount of copies to number specified
  19.                 ' in dialog.
  20.                 '\\------
  21.                 '//------
  22.                 Print.prt(rtbText.Text.Trim) 'calls the prt sub in
  23.                 'the myPrinter class with text (a string) set to the text in the rtb.
  24.                 'Basicly starts the printing process...
  25.                 '\\------
  26.             End If
  27.         End With
  28.     End Sub
  29. End Class
  30.  
  31. 'Print Class
  32. Public Class myPrinter
  33.     Friend TextToBePrinted As String 'Declares TextToBePrinted as a string.
  34.     'Below is the sub that prints the text to the printer.
  35.     Public Sub prt(ByVal text As String)
  36.         TextToBePrinted = text
  37.         Dim prn As New Printing.PrintDocument
  38.         Using (prn)
  39.             prn.PrinterSettings.PrinterName = Form1.printer
  40.             prn.PrinterSettings.Copies = Form1.copies
  41.             '// Adds a handler for PrintDocument.PrintPage
  42.             '(the sub PrintPageHandler)
  43.             AddHandler prn.PrintPage, _
  44.                AddressOf Me.PrintPageHandler
  45.             '\\
  46.             prn.Print() 'Prints.
  47.             '// Removes the handler for PrintDocument.PrintPage
  48.             '(the sub PrintPageHandler)
  49.             RemoveHandler prn.PrintPage, _
  50.                AddressOf Me.PrintPageHandler
  51.             '\\
  52.         End Using
  53.     End Sub
  54.     'Below is code that sets the fonts etc...
  55.     Private Sub PrintPageHandler(ByVal sender As Object, _
  56.        ByVal args As Printing.PrintPageEventArgs)
  57.         Dim myFont As New Font("Microsoft San Serif", 10)
  58.         args.Graphics.DrawString(TextToBePrinted, _
  59.            New Font(myFont, FontStyle.Regular), _
  60.            Brushes.Black, 50, 50)
  61.     End Sub
  62. End Class

Not Commented Code:

vb.net Code:
  1. Public Class Form1
  2.     Public printer As String
  3.     Public copies As Integer
  4.     Private Sub cmdPrint_Click(ByVal sender As System.Object, _
  5.     ByVal e As System.EventArgs) Handles cmdPrint.Click
  6.         Dim Print As New myPrinter
  7.         Dim myprintdialog As New PrintDialog
  8.         With myprintdialog
  9.             If .ShowDialog = Windows.Forms.DialogResult.OK Then
  10.                 printer = .PrinterSettings.PrinterName
  11.                 copies = .PrinterSettings.Copies
  12.                 Print.prt(rtbText.Text.Trim)
  13.             End If
  14.         End With
  15.     End Sub
  16. End Class
  17.  
  18. Public Class myPrinter
  19.     Friend TextToBePrinted As String
  20.     Public Sub prt(ByVal text As String)
  21.         TextToBePrinted = text
  22.         Dim prn As New Printing.PrintDocument
  23.         Using (prn)
  24.             prn.PrinterSettings.PrinterName = Form1.printer
  25.             prn.PrinterSettings.Copies = Form1.copies
  26.             AddHandler prn.PrintPage, _
  27.                AddressOf Me.PrintPageHandler
  28.             prn.Print()
  29.             RemoveHandler prn.PrintPage, _
  30.                AddressOf Me.PrintPageHandler
  31.         End Using
  32.     End Sub
  33.     Private Sub PrintPageHandler(ByVal sender As Object, _
  34.        ByVal args As Printing.PrintPageEventArgs)
  35.         Dim myFont As New Font("Microsoft San Serif", 10)
  36.         args.Graphics.DrawString(TextToBePrinted, _
  37.            New Font(myFont, FontStyle.Regular), _
  38.            Brushes.Black, 50, 50)
  39.     End Sub
  40. End Class