Results 1 to 6 of 6

Thread: Print from VB to EPSON Printer using ESC/POS (Resolved)

  1. #1

    Thread Starter
    Hyperactive Member Pozzi's Avatar
    Join Date
    Feb 2001
    Location
    The Stones!
    Posts
    507

    Question 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)

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    why dont you want to use the

    printer.print method?

  3. #3

    Thread Starter
    Hyperactive Member Pozzi's Avatar
    Join Date
    Feb 2001
    Location
    The Stones!
    Posts
    507
    Hi,

    I've just tried that using the following and I'm able to print to it.

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. Dim P As Object
    4.  
    5. For Each P In Printers
    6.    If P.Port = "COM1:" Then
    7.       Set Printer = P
    8.       Exit For
    9.    End If
    10. Next P
    11.  
    12. Printer.Print "Hello"
    13. Printer.EndDoc
    14.  
    15. End Sub

    Below is an example I found in the EPSON ESC/POS FAQ...

    VB Code:
    1. PRINT #1, CHR$(&H1B);"@"; 'Initializes the printer (ESC @)
    2. PRINT #1, CHR$(&H1B);"a";CHR$(1);'Specifies a centered printing position (ESC a)
    3. PRINT #1, CHR$(&H1B);"!";CHR$(0); 'Specifies font A (ESC !)
    4. PRINT #1, "January 14, 2002 15:00";
    5. PRINT #1, CHR$(&H1B);"d";CHR$(3); 'Prints and 3 line feeding (ESC d)
    6. PRINT #1, CHR$(&H1B);"a";CHR$(0); 'Selects the left print position (ESC a)
    7. PRINT #1, CHR$(&H1B);"!";CHR$(1); 'Selects font B
    8. PRINT #1, "TM-U210B $20.00";CHR$(&HA);
    9. PRINT #1, "TM-U210D $21.00";CHR$(&HA);
    10. PRINT #1, "PS-170 $17.00";CHR$(&HA);
    11. PRINT #1, CHR$(&HA); 'Line feeding (LF)
    12. PRINT #1, CHR$(&H1B);"!";CHR$(17); 'Selects double-height mode
    13. PRINT #1, "TOTAL $58.00"; CHR$(&HA);
    14. PRINT #1, CHR$(&H1B);"!";CHR$(0); 'Cancels double-height mode
    15. PRINT #1, "------------------------------";CHR$(&HA);
    16. PRINT #1, "PAID $60.00";CHR$(&HA);
    17. PRINT #1, "CHANGE $ 2.00";CHR$(&HA);
    18. 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
    VB.Net (VS 2010)

  4. #4

    Thread Starter
    Hyperactive Member Pozzi's Avatar
    Join Date
    Feb 2001
    Location
    The Stones!
    Posts
    507
    Hi,

    Resolved...

    VB Code:
    1. Open "COM1" For Output As #1
    2.  
    3. Print #1, Chr$(&H1B); "@"; 'Initializes the printer (ESC @)
    4. Print #1, Chr$(&H1B); "a"; Chr$(1); 'Specifies a centered printing position (ESC a)
    5. Print #1, Chr$(&H1B); "!"; Chr$(0); 'Specifies font A (ESC !)
    6. Print #1, "January 14, 2002 15:00";
    7. Print #1, Chr$(&H1B); "d"; Chr$(3); 'Prints and 3 line feeding (ESC d)
    8. Print #1, Chr$(&H1B); "a"; Chr$(0); 'Selects the left print position (ESC a)
    9. Print #1, Chr$(&H1B); "!"; Chr$(1); 'Selects font B
    10. Print #1, "TM-U210B $20.00"; Chr$(&HA);
    11. Print #1, "TM-U210D $21.00"; Chr$(&HA);
    12. Print #1, "PS-170 $17.00"; Chr$(&HA);
    13. Print #1, Chr$(&HA); 'Line feeding (LF)
    14. Print #1, Chr$(&H1B); "!"; Chr$(17); 'Selects double-height mode
    15. Print #1, "TOTAL $58.00"; Chr$(&HA);
    16. Print #1, Chr$(&H1B); "!"; Chr$(0); 'Cancels double-height mode
    17. Print #1, "------------------------------"; Chr$(&HA);
    18. Print #1, "PAID $60.00"; Chr$(&HA);
    19. Print #1, "CHANGE $ 2.00"; Chr$(&HA);
    20. Print #1, Chr$(&H1D); "V"; Chr$(66); Chr$(0); 'Feeds paper & cut
    21.  
    22. Close #1

    Regards
    VB.Net (VS 2010)

  5. #5
    New Member
    Join Date
    Mar 2010
    Posts
    1

    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:
    1. Print #1, Chr$(27) + Chr$(64)
    2. Print #1, Chr$(27) + Chr$(114) + Chr$(1) ' Change Ribbon Color
    3. Print #1, "Hello World" + Chr$(10)

    but didn't worked. i want to know what is the wrong with my code?

    ref: Refference

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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
  •  



Click Here to Expand Forum to Full Width