I use:
Visual Studio 8.0
Label design For MySAP

I have created a barcode label and stored as barcode.lbl
This barcode.lbl has two fields:
1. name = &Barcode& {variable barcode field EAN field 12}
2. name = &text1& {variable text field length character field (10)}
I want to link textbox1.text to &Barcode& and link textbox2.text to &text1&
Then just want the label printed on Zebra GX420t.

Thank,

André

Use printing service components of .net framework.

Use printing service components of .net framework.

Can you give me an example of this "printing service components" for my situation

Can you give me an example of this "printing service components" for my situation

There are two basic ways I do this. One is to add a PrintDocument to the form and the other is to declare it in code.

This is the code route:
In the global section of your code add a declaration like so:

Dim WithEvents MyLabel As New Printing.PrintDocument

Then where ever you would like the label to print, put the statement MyLabel.Print

The printing happens in three main events. You get an event that is fired once at the start called BeginPrint, then you have one that is fired for each page called PrintPage and one that fires once at the end called EndPrint.

I do a couple of things in my code that do don't have to, but here it is anyhow:

First thing, the system raises the BeginPrint event

Private Sub Label_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles MyLabel.BeginPrint
        lblStatus.Text = "Looking for label printer."
        Application.DoEvents

        ' Look for the Zebra S600 printer and set it as the printer
       ' I want the job to go to.
        Dim PrinterName As String = ""
        Dim Work As String = ""

        For Each Work In Printing.PrinterSettings.InstalledPrinters
            If Work.ToLower.Contains("s600") Then PrinterName = Work : Exit For
        Next

        If PrinterName.Trim.Length > 0 Then MyLabel.PrinterSettings.PrinterName = PrinterName

        lblStatus.Text = "Using printer " + PrinterName
        DoEvents()

       'Quantity is an NumericUpDown Control.  You can just set this to 1 id you like.
        MyLabel.PrinterSettings.Copies = Quantity.Value
    End Sub

Now I have established which printer I want the job to go to.
The system is going to raise the Print Page event next

Private Sub Label_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles Label.PrintPage
        lblStatus.Text = "Laying out label."
        Application.DoEvents

        ' Start printing
        Dim str As String = ""
        Dim Y As Single
        Dim X As Single
        Dim lh As Single
        Dim MaxPrintWidth As Integer = 320
        Dim MaxPrintHeight As Integer = 400
        Dim RegFont as system.drawing.font
        Dim Black as system.drawing.brush

         RegFont = New System.Drawing.Font("Arial", 10, FontStyle.Regular, Drawing.GraphicsUnit.Point)
         Black = System.Drawing.Brushes.Black

        ' Set some defaults
        Page.LeftMargin = 20
        Page.TopMargin = 30
        lh = Page.LineHeight
        X = 20
        Y = 20

        ' Now the company name in bold.
        X = 150
        Y = 20
        e.graphics.Drawstring("Company Name", RegFont, Black, X, Y)

       lblStatus.Text = "Sending label to printer."
       Application.DoEvents

        e.HasMorePages = False ' Setting this to true will trigger the PrintPage event to go off again once this page prints.
    End Sub

And finally the EndPrintEvent.

Private Sub Label_EndPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles Label.EndPrint
        lblStatus.Text = "Labels printed."
        Application.DoEvents
    End Sub

I appologize in advance for the typos. Some of the code was copy and paste and some of it had to be modified on the fly because I wrote my own printing class to make the generation of pages easier and I didn't want to try to include that whole thing in this little post.

Just one more thing. To get the actual barcode to print, you will need to change the font statement in my sample code to which ever font you have in your system that equates to the EAN barcode.

I use:
Visual Studio 8.0
Label design For MySAP

I have created a barcode label and stored as barcode.lbl
This barcode.lbl has two fields:
1. name = &Barcode& {variable barcode field EAN field 12}
2. name = &text1& {variable text field length character field (10)}
I want to link textbox1.text to &Barcode& and link textbox2.text to &text1&
Then just want the label printed on Zebra GX420t.

Thank,

André

Just one more thing. To get the actual barcode to print, you will need to change the font statement in my sample code to which ever font you have in your system that equates to the EAN barcode.

Thanks for this useful information (code)!

Maybe I'm not entirely clear.
The is a label created with the basic "ZPL programming code" for a Zebra printer.


I have created a barcode label (with ZPL programming code) for a Zebra printer. See appendix.
Now I want only print this barcode label (BarcodeEtiket.txt) from visual basic 8.0.

Before the barcode label (BarcodeEtiket.txt) is printed , i want to fill the following variable fields from Visual Basic 8.0:

groep
inkprijs
maat
verkprijs

barcodenr (of which 2 out of 5 interleaved barcode printing.)

Previsously thanks,

Andre

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.