hi...can someone help me??
a program that i can print barcode from a vb6 application?
once i entered data, (i have already a format for the barcode value),
it will print the barcode once..
then, enter again info, then print..

i have a sato barcode printer ct400.is there any configuration in the printer
or i just need code????

thanks..

Dani AI

Generated

If you want true “type and print” behavior with a SATO CT400 from VB6, you have two workable paths. Fonts (as noted) are OK for simple Code 39 jobs, but you must add the required start/stop asterisks and maintain quiet zones and height, or scans will be unreliable. Driving the printer in its native SBPL language is more robust and lets the printer handle positioning, quantity, and media feed. SBPL jobs generally start with ESC+A and end with ESC+Z; Code 39 specifically requires the “*” guards. (manualslib.com)

Below is a minimal VB6 routine that sends a RAW SBPL string to the spooler. Call it right after you save the user’s input so it prints one label per entry. The key is pDatatype = "RAW" with WritePrinter. (learn.microsoft.com)

' Module-level WinSpool declares
Private Type DOCINFO: pDocName As String: pOutputFile As String: pDatatype As String: End Type
Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pName As String, ph As Long, ByVal pDefault As Long) As Long
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal h As Long) As Long
Private Declare Function StartDocPrinter Lib "winspool.drv" Alias "StartDocPrinterA" (ByVal h As Long, ByVal Level As Long, di As DOCINFO) As Long
Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal h As Long) As Long
Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal h As Long) As Long
Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal h As Long) As Long
Private Declare Function WritePrinter Lib "winspool.drv" (ByVal h As Long, pBuf As Any, ByVal cbBuf As Long, pcbWritten As Long) As Long

Public Function RawToPrinter(ByVal printerName As String, ByVal data As String) As Boolean
    Dim h As Long, di As DOCINFO, bytes As Long, buf() As Byte
    If OpenPrinter(printerName, h, 0) = 0 Then Exit Function
    di.pDocName = "VB6 SBPL": di.pDatatype = "RAW"
    If StartDocPrinter(h, 1, di) > 0 Then
        StartPagePrinter h
        buf = StrConv(data, vbFromUnicode)
        Call WritePrinter(h, buf(0), UBound(buf) + 1, bytes)
        EndPagePrinter h: EndDocPrinter h
        RawToPrinter = (bytes = UBound(buf) + 1)
    End If
    ClosePrinter h
End Function

' Example: one Code 39 label "*12345*" at H=0100,V=0025, height=100, qty=1
Dim sbpl As String
sbpl = Chr$(27) & "A" & Chr$(27) & "H0100" & Chr$(27) & "V0025" & _
       Chr$(27) & "B103100*12345*" & Chr$(27) & "Q1" & Chr$(27) & "Z"
Call RawToPrinter("SATO CT400", sbpl)

Tips: if your CT400 is set to Non-Standard control characters, either switch to Standard ESC on the panel or issue the LD command first as SATO documents for CT/CX series; otherwise the printer will ignore your ESC codes. Also, SBPL will report command errors (e.g., bad positions) to help you debug. (satoamerica.com)

For and : this approach avoids font quirks and gives reliable one-label-per-entry printing with CT400 hardware.

Recommended Answers

All 5 Replies

I think you need the barcode font(s) for the specific type(s) of barcode(s) you'll be using. Plus you'll probably have to communicate directly with the printer. On the Sato website is programming information for several models.

One of the reason is that your generated barcodes are not compatible with related barcode specifications so that the printer can not scan them out. You may try another barcode generation component to generate standard barcode images. If this fails, you need to ask your printer supplier for help.

just created a function to print and call it when inoutting of info is done..

Can anyone of u send me the code for barcode generator using VB 6.0 . This will be help to my project

. I never had any issue getting bar codes out printed. But I may have cheated. That is I installed a bar code font and then printed in that font. Maybe too easy today.

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.