Click here to Skip to main content
15,905,238 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello friends
My name is Sarfaraz. I am developing a software for a client who needs to print receipts on a Dot Matrix printer.
I know how to print values of Text box but that is not the best way to print on Dotmatrix printer.
Please help me in the following:
1. Should i load the details of text boxes and listbox to a grid and then print on a receipt. or
2. Should I save the contents of text boxes and listbox to text file and print. or
3. Sould I use crystal reports for the recipt to print.
Please help me in that.
Thank you
Sergey Alexandrovich Kryukov 18-Apr-14 12:06pm    
Why not printing on it as on any other printer installed in the system?
When you say "text box", the question is: which one? Full type name, please.

1 solution

For Dot Matric printer, #2 is the best option. Crystal reports and other graphics format will be really slow and will use lot of ink.

Save to a text file and execute the shell command

type "filename.txt" > prn
Share this answer
sarfarazbhat 18-Apr-14 13:24pm    
Dear Akbar Bhai
Please elaborate I am new to actually i am able to write the values to a text file like

Private Sub btnnew_Click(sender As Object, e As EventArgs) Handles btnnew.Click
Dim file_name As String = Application.StartupPath() & "/text.dat"
Dim stream_writer As New IO.StreamWriter(file_name, False)
End Try
Catch exc As Exception
' Report all errors.
MsgBox(exc.Message, MsgBoxStyle.Exclamation, "Read " & "Error")
End Try

But I need an example for help for printing like you mentioned type "filename.txt" > prn
Thank you
Akbar Ali Hussain 22-Apr-14 15:16pm    
After creating the file, you can send that file to Printer using Shell command. Refer code below...

Dim file_name As String = Application.StartupPath() & "/text.dat"
Dim command as String = "type " + file_name + " > prn"
Dim proc As Process = New System.Diagnostics.Process()
proc.StartInfo = New System.Diagnostics.ProcessStartInfo("cmd", "/c " & command)
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.RedirectStandardError = True
proc.StartInfo.UseShellExecute = False
proc.StartInfo.CreateNoWindow = True
proc.EnableRaisingEvents = False

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900