How to print some data from bas Module

Here is the sample code you can use to print your data from the bas module:

Module modMain
  Dim sText As String
  Public Sub printRecord()
      Dim pDocument As New Printing.PrintDocument
      AddHandler pDocument.PrintPage, AddressOf pd_PrintPage
      sText = "DotNet Blogger - Your favorite Microsoft Visual Studio .Net Programming Blog."
      pDocument.Print()
  End Sub

  Private Sub pd_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
      'this uses a module level variable
      e.Graphics.DrawString(sText, New Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, 50, 50)
  End Sub
End Module

Tested with VS 2008

If you found any issues with the code posted above, please leave a comment. We will fix the code as soon as possible.

Incoming search terms:

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>