Hi
I have an existing Visual Basic 6 program which prints to an attached (LPT1) Dot Matrix Printer.
Printing is done by first sending the output to a file and from there sending it to the printer.
There are a set of Escape Sequences like

Print #1 chr(15); chr(3); strVarName 

or

Print #1 chr(15); strVarName ; Chr(18)

to make the font condensed, bold etc., which print to the file from which the output is sent to the printer.
The customer has purchased a new Epson TM - 220D , USB POS printer having a 76mm width paper roll. I have suitably modified the vb6 code and it now prints to a USB printer. However, I find that the existing escape sequences are ignored by this printer.
My existing code uses the following and works

'Codes used are as follows:
'Chr(14)---Double Wide
'Chr(15)---Codensed Mode
'Chr(18)---Cancel Condensed Mode
'Chr(69)---Emphasized Mode (makes text appear bold)
'Chr(27)---Emphasized Mode(makes text Bold)
'Chr(9)----Horizontal Tab
'Chr(1)---Center Align
'Chr(2)---Right Align
'Chr(3)---Left Align

Print #1, Chr(15); Chr(14); strTemp; Chr(18) 'Print Bold/condensed.
This above has been working on a 80 column dot matrix Epson printer for years now!

My new Epson TM - 220D , USB POS printer's manual states some escape sequences such as

#B,tL, bL, bC, 1C, 2C, 3C, 4C, cA, rA, N.

But doesn't mention how these are to be used.

I tried....

Print #1, "\bL"; strTemp
Print #1, "\#B"; strTemp

But I'm not able to print one bold line.

Will someone please help out?

Thanks. ...

Recommended Answers

All 10 Replies

But I'm not able to print one bold line.

Will someone please help out?

I would suggest not using escape sequences and LPT1. Instead I would load a driver for the printer and print using the following:

Printer.Print

I've seen code like you mentioned and I believe the easier way is to just use the driver and set the Printer device to the proper printer device. You should be able to set the font along with the font properties as you desire using VB6's printer object.

But if you want to do it like you mentioned, then I believe you need to send the proper escape sequence to notify the printer that you are going to send an escape code.


Don't know if you want to go that route, but in the long run that would probably be the easier way and allow for the use of different printers not tied to

If you want to talk directly to the printer, you will need to use the API. On the index tab type in OpenPrinter and hit enter. Scroll down to the bottom and click on Printing and Print Spooler Functions to see the other API's you will need.

Good Luck

After doing some research, I have discovered that there are 2 ways to send output from Visual Basic 6 to the Epson TM-220D USB printer.

A) Place Epson's control (.ocx Component) on the VB6 form and use the fuctions, including the escape sequences.

B) Send output through an intermediary Notepad file, as outlined in post #1 above.

Using A above:
Epson's accompanying Manual's CD gives VB6 examples. The very first, is a simple "Hello world" print example. They even provide examples of printing the escape sequences.

However, none of examples print anything to the printer !!

I would love using this method; and place the Epson control on my VB6 form. In an instant, I could have access to all the escape sequences I need.

Using B above:
I can't find Escape sequences to use this method.


The only reason I send print output through an intermediary file to the printer is because Windows Xp unlike it's predecessors(Works well in Windows 98!) seems to disallow printing from VB6 directly to the printer.

Is it possible to send print output from VB6 directly to the printer (without using a notepad file as a go between)?
If yes, then why am I not able to do so, in Win Xp?

Yes it is possible with the Printer object, i.e. Printer.Print "Hello World" Printer.EndDoc and then you could control the positioning of where "Hello World" gets printed by using the currentx/y properties.

Printer.CurrentX = 100
Printer.CurrentY = 200
Printer.Print "Hello World"
Printer.EndDoc

Good Luck

I want to print directly to USB Printer using Escape commands.
Can Any Body help

Hi please help me,

i use Open "LPT1:" as command to send escape sequences to printer. how to change it to usb printer port. please help.

Regards,
Manikandan

i use Open "LPT1:" as command to send escape sequences to printer. how to change it to usb printer port. please help.

install the local printer as generic text only on windows and share it. for example, your computer name on network is server and your printer share name is generic. then, instead of open LPT1 , you will open \\server\generic as the port. works well and solve the problem.

Opspl programme

In given sample you have change the device name as per your configuration. Before using this examples we have to setup POS printer. (install .ocx for the printer).

e.g. instead of "Unit1" user your device name.

I'm able to print ESC commands on USB POS Printer........................

Yes it is possible with the Printer object, i.e. Printer.Print "Hello World" Printer.EndDoc and then you could control the positioning of where "Hello World" gets printed by using the currentx/y properties.

Printer.CurrentX = 100
Printer.CurrentY = 200
Printer.Print "Hello World"
Printer.EndDoc

Please help me. I am using code in above method but printer ejecting paper. How can stop paper without ejecting ( i am using continious paper to print invoice)

Firstly, you have hijacked a 6 YEAR!! old thread. :) You need to start your own NEW thread.

Your page will "eject" because you have used the .EndDoc line. That tells the printer that you are done printing. You need to add all your code for viewable print and then end the print job, otherwise it will hang in memory and you will have a crashed app if you want to print another page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.