VB.NET - Print in Dot Matrix using VB.Net 2005

Asked By IQBAL AHMED.G on 10-Jun-08 02:37 AM

I have done a program in VB.Net. I need to print my reports in Dot Matrix Printer.

How to write the code in VB.Net 2005.

Please help



check these.. - Santhosh N replied to IQBAL AHMED.G on 10-Jun-08 02:43 AM

If you are using crystal reports there you need not do that, unless you are customizing your printouts..

Check these articles on how to do in Vb.net step by step..



try this - sri sri replied to IQBAL AHMED.G on 10-Jun-08 03:04 AM

There is no separe code for dot matrix printer.
you have to design the reports using crystal reports

Right click in the solution explore ,
click add new items,
choose crystal report(If there is no crystal report then install it) and desing your report.

for more information about crystal report in vb.net refer the below links

Print in Dot Matrix - Shailendrasinh Parmar replied to IQBAL AHMED.G on 10-Jun-08 03:12 AM

See the following links, you may get your solution ::


try this code... - Vasanthakumar D replied to IQBAL AHMED.G on 10-Jun-08 03:28 AM


try the below code...

Protected Sub PrintFile_Click(sender As Object, e As System.EventArgs)printDialog1.Document = ThePrintDocument
Dim strText As String = Me.richTextBox1.Text
myReader =
New StringReader(strText)
If printDialog1.ShowDialog() = DialogResult.OK Then
End If
Sub 'PrintFile_Click
Protected Sub ThePrintDocument_PrintPage(sender As Object, ev As System.Drawing.Printing.PrintPageEventArgs)
Dim linesPerPage As Single = 0
Dim yPosition As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = ev.MarginBounds.Left
Dim topMargin As Single = ev.MarginBounds.Top
Dim line As String = Nothing
printFont As Font = Me.richTextBox1.Font
Dim myBrush As New SolidBrush(Color.Black)
' Work out the number of lines per page, using the MarginBounds.
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
' Iterate over the string using the StringReader, printing each line.
While count < linesPerPage And Not ((line <<= myReader.ReadLine()) Is Nothing) 'ToDo: Unsupported feature: assignment within expression. "=" changed to "<="
' calculate the next line position based on
' the height of the font according to the printing device yPosition = topMargin + (count * printFont.GetHeight(ev.Graphics));// draw the next line in the rich edit control
ev.Graphics.DrawString(line, printFont, myBrush, leftMargin, yPosition, New StringFormat())
count += 1
End While ' If there are more lines, print another page. if (line != null)ev.HasMorePages = True
ev.HasMorePages = False
End Sub 'ThePrintDocument_PrintPage

error in preview - Mona Salama replied to IQBAL AHMED.G on 07-Sep-09 10:01 AM

I'm already changed the reports printer setup to dot matrix and size [letter fanfold 8 1/2 x 11 in] and everything seems good but when I delivered the exe to the client  all the reports didn't appear correct in preview .could you help me fix this issue .