473,419 Members | 2,049 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Printing to a ticket thermal printer from ancient VB6.0 - apparently loses bytes

Hi,
This is my first post and need help with an unexpected problem.
I am an experienced C language programmer but don't have much experience with VB6.0, please excuse me.
I will try to describe the problem in detail and as short as possible.

We bought a chinese thermal printer 55 mm paper width. I need to print barcode labels for marking and classifying parts and components in a warehouse.
I am using Windows 10 professional and the ancient Visual Basic 6.0 IDE installed on Windows 10.
I have made several programs using all VB6.0 basic functions including serial ports, timers, etc.
No problems at all so far.

As many other printers, this POS58A printer has a traditional RS232 port and a USB printer port as well.
The serial connection needs no special driver installed. When using the USB printer port needs a driver supplied with the printer. When this USB driver is installed in Windows 10, the printer appears as POS58A along with other installed printers eg: HP1102P , Microsoft print to PDF, etc.

My VB6.0 program detects all printers available including de POS58A thermal printer.
When using:

Expand|Select|Wrap|Line Numbers
  1. Printer.Print "Hello World" & vbCrLf
  2. Printer.EndDoc
...the printer works perfectly well.

These kind of label printers have built in barcode and QR code functions. By sending simple ASCII table bytes
to the printer, the printer understands an escape sequence that produces several barcode standards.
If you need to print a CODE93 type barcode VB6.0 should issue the following:

Expand|Select|Wrap|Line Numbers
  1. Dim Barcode as String
  2.  
  3. Barcode = "HELLO1234567"
  4. Printer.Print Chr$(29) & "k" & Chr$(72) & Chr$(12) & Barcode & vbCrLf; ' Print bar code93
  5. Printer.EndDoc
The first Chr$(29) is a GS ASCII code that starts the escape sequence for a barcode.
The following "k" follows as part of this sequence. The Chr$(72) instructs the printer to generate
specifically a CODE93 type barcode,among many other possible formats, by changing this number.
The CHR$(12) specifies the length of the barcode in digits. Finally, the contents of the barcode
itself, simple ASCII uppercase characters. The vbCrLf is not required, it just line feeds after
de barcode is printed.

This should print a CODE93 type barcode right away, but it doesn't.

Instead, it prints part of the HELLO1234567, but starting with some garbled characters, as if the
control codes (or non printable characters), those between hex 00 and hex 1F in the ASCII table
are being in some way filtered by the printing process. This extends to almost any special command
for the printer to print different fonts, underline, double width, etc.

Some comments here:

1.
As I run out of ideas, I decided to write exactly the same program but for the serial port using
MS comm control 6.0 (SP6) serial object. I changed the cable, and I have the complete program
up and running.

Instead of the previous code, I am using:

Expand|Select|Wrap|Line Numbers
  1. MSComm1.Output = Chr$(29) & "k" & Chr$(72) & Chr$(12) & Barcode & vbCrLf ' Print bar code93
2.
The printer also installs a driver test and configuration software that allows the user to select the
way to talk to the printer, installed printer drivers or serial ports. The self test button on this
program prints a long paper strip full of all possible types of barcodes, QR code, fonts and features.
I can print this test perfectly using the POS58A installed driver and also the serial port, which requires
just to change the cable and switch to the other printer connector. Meaning that Windows is using the
driver to print.

3.
I found in a website a solution that treats the printing job by opening the port as a file and
writing to the file and closing the file when finished. I requires to call the printer by a name such
as LPT1 or the like, but it didn't work. Nothing was printed.

I am sorry for the long explanation but maybe this will help to avoid unnecessary writing.

Could you please help me find a solution for this problem?

Thank you.
Jul 25 '23 #1
2 20602
MerlinTheGreat
6 Nibble
Some questions:
  • Did you use the correct controlling characters for the command?
    Manuals can be quite confusing.
  • Have you tried composing the print command first as a string, and then sending that string to the printer?
    Sometimes the command gets mutilated when composing it directly to the printer.
Aug 13 '23 #2
cactusdata
214 Expert 128KB
It could be Unicode that messes up the "k". Try:
Expand|Select|Wrap|Line Numbers
  1. Printer.Print = Chr$(29) & StrConv("k", vbFromUnicode) & Chr$(72) & Chr$(12)
  2. ' or:
  3. Printer.Print = Chr$(29) & ChrB(107) & Chr$(72) & Chr$(12)
Aug 14 '23 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: yulyos | last post by:
Hi, printing to the printer with vb.net from right to left how do i print to the printer from right to left with vb.net example in vb6: Printer.RightToLeft = True
3
by: alan | last post by:
I'm now using VB.NET to write a POS which it need to drive the epson thermal printer. I have no problem to use the printer by using "PrintDocument" onject provided by Vb.NET. But I think the speed...
2
by: alan | last post by:
I'm now using vb.net to write a POS system with a epson thermal printer. I use the ocx that provided by Epson to drive the printer. It's not the problem if I just using 1 computer vs 1 thermal...
1
by: Paolo matador | last post by:
Hi All, i have a little problem with my web application. I need to print a web page, shrinked on a thermal printer that not supporting A4 format. The printer is this:...
2
by: Beginner | last post by:
I have to print a Fedex shipping label on a Zebra(thermal) printer. I initially had the label information in a base64 string which I decoded into a memory stream. Now I need to send this memory...
1
by: deric | last post by:
Hi! I'm new to VB.net programming on printing a page to a thermal printer (Epson T88IV). I really had a hard time figuring out how to code the printing of a bitmap image and some text, while sending...
12
by: ThaSaltyDawg | last post by:
I have an application that prints to a Thermal Printer..These are the older printers (brand Zebra 3742) and uses the Serial Com Port 1 & 2. I have that working. We now have two new printers (brand...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.