Print Barcode Labels with vb.net

Good afternoon everyone! I had an extremely quiet evening last night and this morning. We are really at crunch time at work right now but I think I am where I need to be with what I need to do.

Anyway, today’s topic is one that can throw a lot of for fits. We need to print barcode labels but some characters don’t translate as you would expect in print. So this class is a little old but it still works. Make it a great day!

‘This call is required by the Windows Form Designer. InitializeComponent()

‘Add any initialization after the InitializeComponent() call

End Sub

‘Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub

‘Required by the Windows Form Designer Private components As System.ComponentModel.IContainer

Public Class TextPrint ‘ Inherits all the functionality of a PrintDocument Inherits Printing.PrintDocument ‘ Private variables to hold default font and text Private fntPrintFont As Font Private strText As String Private strText2 As String Private PrintBarCodeText As String Public Sub New(ByVal Text As String, ByVal Text2 As String) ‘ Sets the file stream MyBase.New() strText = Text strText2 = Text2 End Sub Public Property Text() As String Get Return strText End Get Set(ByVal Value As String) strText = Value End Set End Property Public Property Text2() As String Get Return Trim(strText2) End Get Set(ByVal Value As String) strText2 = Trim(Value) End Set End Property Public Property CodeText() As String Get PrintBarCodeText = Trim(Replace(strText, "*", " ")) Return PrintBarCodeText End Get Set(ByVal Value As String) If PrintBarCodeText = "" Then PrintBarCodeText = Trim(Replace(Value, "*", " ")) End If PrintBarCodeText = Value End Set End Property Protected Overrides Sub OnBeginPrint(ByVal ev As Printing.PrintEventArgs) ‘ Run base code MyBase.OnBeginPrint(ev) ‘ Sets the default font If fntPrintFont Is Nothing Then fntPrintFont = New Font("Times New Roman", 12) End If End Sub Public Property Font() As Font ‘ Allows the user to override the default font Get Return fntPrintFont End Get Set(ByVal Value As Font) fntPrintFont = Value End Set End Property Protected Overrides Sub OnPrintPage(ByVal ev As Printing.PrintPageEventArgs) ‘ Provides the print logic for our document

‘ Increase current char count intCurrentChar += intCharsFitted ‘ Check whether we need to print more If intCurrentChar < strText.Length Then ev.HasMorePages = True Else ev.HasMorePages = False intCurrentChar = 0 End If End Sub Public Function UpgradeZeros(ByVal Input As Integer) As Integer ‘ Upgrades all zeros to ones ‘ – used as opposed to defunct IIF or messy If statements If Input = 0 Then Return 1 Else Return Input End If End Function

hi.. what should I do if I wanna print the barcode from Textboxes like the following format?. eg.||||||| |||||||| |||||||| ||||||123456ABCDEFG HIJLMNOPTextbox data come from Database columns. And then, will print the above format without using the PrintDocument or PrintDialogue controls. Thank you.