Link to home
Start Free TrialLog in
Avatar of ycl
ycl

asked on

How to directly send ESC code to printer?

I want to send some ESC sequences directly to printer. How to do this?
Avatar of vettranger
vettranger

Set a string variable equal to your escape sequence, and then use the printer object to print it :

dim e$

e$ = chr$(94) & chr$(108) ' & whatever
printer.print e$



Avatar of ycl

ASKER

Your direction doesn't take effect,for instance when I send "chr(&H1b) & chr(&h40)" to EPSON LQ-1600 printer , It prints the sign "@",instead of initiate the printer.
I believe there's a control code you need to send before the escape code sequence indicating that an escape code sequence is about to follow. This differs by printer, but should be in the printer docs somewhere.
The ESC (escape) character is usually ASCII 27
Anytime you need to send an ESC preface the codes with ESC$

DIM ESC$
ESC$=CHR(27)

Printer.Print ESC$ & chr(&H1b) & chr(&h40)

(not the best naming convention - but I think you'll get the idea)
Umm, scottsch, with the exception of naming ASCII 27 (which will work on many but not all printers), you've given the same information I did in my answer and comment ... frowned on in EE.

My original answer was correct, ycl needed some information on how to properly set up his escape code sequence beyond his original question.
Avatar of ycl

ASKER

I'm puzzled. Is 27 not equal to &h1B?
ASKER CERTIFIED SOLUTION
Avatar of mark2150
mark2150

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok you rejected the proposed answer. You find any of the other comments worthwhile?

M
Finalized.
Moondancer - EE Moderator