|
-
Aug 2nd, 2004, 06:19 AM
#1
Thread Starter
Hyperactive Member
Print from VB to EPSON Printer using ESC/POS (Resolved)
Hi,
Has anyone, or does anyone know how to print from VB to an EPSON printer (TM-88III) using ESC/POS?
The printer would be connected to my COM Port.
Any help or examples would be much appreciated.
Regards
Last edited by Pozzi; Aug 2nd, 2004 at 08:37 AM.
VB.Net (VS 2010)
-
Aug 2nd, 2004, 06:41 AM
#2
why dont you want to use the
printer.print method?
-
Aug 2nd, 2004, 07:53 AM
#3
Thread Starter
Hyperactive Member
Hi,
I've just tried that using the following and I'm able to print to it.
VB Code:
Private Sub Command1_Click()
Dim P As Object
For Each P In Printers
If P.Port = "COM1:" Then
Set Printer = P
Exit For
End If
Next P
Printer.Print "Hello"
Printer.EndDoc
End Sub
Below is an example I found in the EPSON ESC/POS FAQ...
VB Code:
PRINT #1, CHR$(&H1B);"@"; 'Initializes the printer (ESC @)
PRINT #1, CHR$(&H1B);"a";CHR$(1);'Specifies a centered printing position (ESC a)
PRINT #1, CHR$(&H1B);"!";CHR$(0); 'Specifies font A (ESC !)
PRINT #1, "January 14, 2002 15:00";
PRINT #1, CHR$(&H1B);"d";CHR$(3); 'Prints and 3 line feeding (ESC d)
PRINT #1, CHR$(&H1B);"a";CHR$(0); 'Selects the left print position (ESC a)
PRINT #1, CHR$(&H1B);"!";CHR$(1); 'Selects font B
PRINT #1, "TM-U210B $20.00";CHR$(&HA);
PRINT #1, "TM-U210D $21.00";CHR$(&HA);
PRINT #1, "PS-170 $17.00";CHR$(&HA);
PRINT #1, CHR$(&HA); 'Line feeding (LF)
PRINT #1, CHR$(&H1B);"!";CHR$(17); 'Selects double-height mode
PRINT #1, "TOTAL $58.00"; CHR$(&HA);
PRINT #1, CHR$(&H1B);"!";CHR$(0); 'Cancels double-height mode
PRINT #1, "------------------------------";CHR$(&HA);
PRINT #1, "PAID $60.00";CHR$(&HA);
PRINT #1, "CHANGE $ 2.00";CHR$(&HA);
PRINT #1, CHR$(&H1D);"V";CHR$(66);CHR$(0); 'Feeds paper & cut
I tried sending this to the printer by changing 'PRINT #1' to 'Printer.Print', it got there but took a long time, and not fully.
In the FAQ it just shows the above as an example, how do I get the above sent to the printer?
Also the printer object is fine, if the printer is installed. But what if the printer is just attached to COM1, but not installed in windows and the COM settings are being read in from an ini file?
Regards
-
Aug 2nd, 2004, 08:34 AM
#4
Thread Starter
Hyperactive Member
Hi,
Resolved...
VB Code:
Open "COM1" For Output As #1
Print #1, Chr$(&H1B); "@"; 'Initializes the printer (ESC @)
Print #1, Chr$(&H1B); "a"; Chr$(1); 'Specifies a centered printing position (ESC a)
Print #1, Chr$(&H1B); "!"; Chr$(0); 'Specifies font A (ESC !)
Print #1, "January 14, 2002 15:00";
Print #1, Chr$(&H1B); "d"; Chr$(3); 'Prints and 3 line feeding (ESC d)
Print #1, Chr$(&H1B); "a"; Chr$(0); 'Selects the left print position (ESC a)
Print #1, Chr$(&H1B); "!"; Chr$(1); 'Selects font B
Print #1, "TM-U210B $20.00"; Chr$(&HA);
Print #1, "TM-U210D $21.00"; Chr$(&HA);
Print #1, "PS-170 $17.00"; Chr$(&HA);
Print #1, Chr$(&HA); 'Line feeding (LF)
Print #1, Chr$(&H1B); "!"; Chr$(17); 'Selects double-height mode
Print #1, "TOTAL $58.00"; Chr$(&HA);
Print #1, Chr$(&H1B); "!"; Chr$(0); 'Cancels double-height mode
Print #1, "------------------------------"; Chr$(&HA);
Print #1, "PAID $60.00"; Chr$(&HA);
Print #1, "CHANGE $ 2.00"; Chr$(&HA);
Print #1, Chr$(&H1D); "V"; Chr$(66); Chr$(0); 'Feeds paper & cut
Close #1
Regards
-
Mar 16th, 2010, 03:58 AM
#5
New Member
Re: Print from VB to EPSON Printer using ESC/POS (Resolved)
Great.... it works.....
can anyone help me to explain, how to print in red with this pos printer.
i tried this
vb Code:
Print #1, Chr$(27) + Chr$(64) Print #1, Chr$(27) + Chr$(114) + Chr$(1) ' Change Ribbon Color Print #1, "Hello World" + Chr$(10)
but didn't worked. i want to know what is the wrong with my code?
ref: Refference
-
Mar 16th, 2010, 05:15 AM
#6
Re: Print from VB to EPSON Printer using ESC/POS (Resolved)
i believe it should be 5 for red
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|