Printing to POS thermal label printer problem using Print.printer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BobBerner28
    New Member
    • Jul 2023
    • 3

    Printing to POS thermal label printer problem using Print.printer

    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:

    Code:
    Printer.Print "Hello World" & vbCrLf
    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:

    Code:
    Dim Barcode as String
    
    Barcode = "HELLO1234567"
    Printer.Print Chr$(29) & "k" & Chr$(72) & Chr$(12) & Barcode & vbCrLf; ' Print bar code93
    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:

    Code:
    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.
Working...