| Home: Products: VB Barcode Integration Guide and Tutorial: |
|
| Product(s): | Advantages and Disadvantages: |
| Self Checking Barcode Fonts |
|
| .NET Forms Controls |
|
| ASP.NET Web Server Controls |
|
| VB Module Integration with Barcode Fonts |
|
| Native Windows Barcode DLL with Barcode Fonts or the Universal Barcode Font |
|
| PDF417 Font and Encoder or the Data Matrix Font and Encoder |
|
| Barcode ActiveX Controls |
|
| Crystal Reports Integration | When printing with Crystal Reports, refer to the Crystal Reports Integration Guide for the best implementation method. |
| Self-Checking Fonts in VB 6: |
Self-Checking Barcode Fonts (including MICR and OCR fonts) are compatible with Visual Basic and may be used with ease. To use a self-checking font such as Code 39, insert an asterisk "*" before and after the data encoded. Therefore, to encode TEST3OF9 in a barcode, the text of *TEST3OF9* would need to be present in a field with the Code 39 font selected. When using the Codabar Font for numbers only, use the 'A' character instead of the asterisks.
The following is a VB 6 example of printing the
Code 39 bar-code font
from Visual Basic, where variable is a string to encode in
the barcode:
Printer.FontName = "IDAutomationHC39M"
Printer.CurrentY = 3000
Printer.FontSize = 12
Printer.Print "*" & variable & "*"
Printer.FontSize = 10
Printer.FontName = "Helv" 'Switch to a text font
Printer.Print "The above barcode is code-39"
Printer.EndDoc 'This tells the printer to eject the page
Barcode may also be printed from a field in a database via the data
control, for example:
Printer.Print "*" & Data1.Recordset("field1")
& "*"
The start and stop characters may also be appended to the variable,
for example:
variable ="*" & DataString & "*"
Printer.Print variable
When printing with Crystal Reports, refer to the Crystal Reports Integration Guide for the best implementation method.
|
Self-Checking Fonts in VB .NET: |
'Set the font of the font object and the
data to encode
PrintFont = New Font("IDAutomationHC39L", 12)
VariableToPrint = "*" & "128-39-200-128" & "*"
'Add an event handler that will be called
for each page that is generated
AddHandler PrintDoc.PrintPage, AddressOf Me.PrintDoPrintPage
'Initiate the printing of the document
PrintDoc.Print()
'****
The following code should be placed in the event handler, which places
the data on the page:
Dim linesPerPage As Single = 0
'Number of lines (bar codes) that you will be able to fit on the page
Dim yPos As Single = 0
'yPos on the page of the bar code
Dim leftMargin As Single = ev.MarginBounds.Left 'left
margin of bar code
Dim topMargin As Single = ev.MarginBounds.Top 'top margin of
bar code
Dim line As String = Nothing 'String
that font will be applied to and printed
When printing with Crystal Reports, refer to the Crystal Reports Integration Guide for the best implementation method.
|
Visual Basic Barcode Font Module Integration |
The IDAutomation VB Font Module (or source code from the module) calculates the start, stop and check digits for the barcode and returns a text string, that when combined with the appropriate IDAutomation Barcode Font, creates a correct barcode. VB developers may add this module to their Visual Basic applications and access the functions directly. Using this module, there is nothing to distribute with the application except the barcode font because the functions of the module are compiled into the EXE file.
Note: Depending on the method used, a parameter may be required. For example, Code128("123456",0,True).
| Function | Notes |
|
VB 6 module: Code128(DataToEncode, Optional ReturnType, Optional ApplyTilde) VB.NET module: Code128(DataToEncode, ApplyTilde) Code128HR(DataToEncode, ApplyTilde) |
The recommended and primary Code 128 method
that will automatically encode any data from ASCII 1 to ASCII
127. This method
contains many options. (DataToEncode, 0) formats barcode output string to the Code 128 barcode fonts. (DataToEncode, 0, True) formats barcode output string for the Code 128 barcode fonts with ApplyTilde enabled. (DataToEncode, 1) returns the human readable text. (DataToEncode, 2) returns only the check digit.
The Code128HR function is only available
in VB.NET. |
| Code128a(DataToEncode) | Caution: Entering a lower
case character with this method will create a function. Use
the
character values 64 through 95 from set A to create functions.
Formats output to the Code 128 barcode fonts. |
| Code128b(DataToEncode) | Returns codes formatted to the Code 128 character set B. Formats output to the Code 128 bar code fonts. |
|
Code128c(DataToEncode, Optional ReturnType) |
This code128 function "interleaves"
numbers into pairs for high density. (DataToEncode, 0) formats output to the Code 128 barcode fonts. (DataToEncode, 1) returns the human readable text with the check digit included. (DataToEncode, 2) returns only the check digit. |
| I2of5(DataToEncode) | This function "interleaves" numbers into pairs for high density without check digits and formats the return string to the Interleaved 2 of 5 font. |
|
I2of5Mod10(DataToEncode, Optional ReturnType) |
(DataToEncode, 0) performs
the mod10 checksum calculation for increased accuracy and formats
the return string to the
Interleaved
2 of 5 font. MOD 10 checksums are required by USPS for special
services and for SSC-14 when using Interleaved 2 of 5 for that
purpose. (DataToEncode, 1) returns the human readable data with the MOD10 check digit included. (DataToEncode, 2) returns the MOD10 check digit. |
| Code39(DataToEncode) | Formats the output to print using Code 39 fonts. |
|
Code39Mod43(DataToEncode, Optional ReturnType) |
(DataToEncode, 0) performs
the mod43 checksum calculation for increased accuracy and then
formats the output to print using
Code 39 fonts.
The mod43 checksum is usually required for LOGMARS and HIBC
applications. (DataToEncode, 1) returns the human readable data with the check digit included. (DataToEncode, 2) returns only the check digit. |
| Codabar(DataToEncode) | Formats the output to print using Codabar fonts. |
| UCC128(DataToEncode) | This symbology option encodes an even number of number digits and includes the FNC1 character in set C as required. Use Code 128 Auto to encode additional FNC1 codes or data containing text or odd numbers. Use the UCC128 function only for UCC-128 applications where the input data is an even number such as in SSCC-18 and SCC-14 barcodes. For example, to encode an SSCC-18 barcode, enter 00000123455555555558 as the data input. Formats output to the Code 128 barcode fonts. |
| Postnet(DataToEncode, Optional ReturnType) |
Enter a single string of Zip, Zip + 4 or
Zip + 4 + Delivery Point. The DataToEncode must be a number
and can include dashes and spaces. (DataToEncode, 0) formats output to the POSTNET barcode fonts. (DataToEncode, 1) returns the human readable data with the check digit included. (DataToEncode, 2) returns only the check digit. |
| MOD10(DataToEncode) | Returns the MOD 10 check digit for a given string of numbers according to the UCC/EAN method. |
| RM4SCC(DataToEncode) | Formats the output to print using RM4SCC fonts. Checksum calculated according to the mailsort customer barcoding specification. |
|
MSI(DataToEncode, Optional ReturnType) |
(DataToEncode, 0) formats
output to the MSI
barcode fonts. (DataToEncode, 1) returns the human readable data with the check digit included. (DataToEncode, 2) returns only the check digit. |
| Code11(DataToEncode) | Only the "C" check digit is calculated which is the standard when encoding 10 digits or less. Formats output to the Code11 barcode fonts. |
| UPCa(DataToEncode) | DataToEncode is a UPC-A number string of 11, 12, 13, 14, 16 or 17 digits with or without a check digit, add-ons are supported. Formats output to the UPC/EAN barcode font. Entering incorrect data will create a barcode containing all zeros. |
| UPCe(DataToEncode) | DataToEncode is a UPC-A number string of 11, 12, 13, 14, 16 or 17 digits with or without a check digit, add-ons are supported. The purpose of this function is to print the UPC-E barcode from a UPC-A barcode that can be compressed. Formats output to the UPC/EAN barcode font. Entering incorrect data will create a barcode containing "00005000000". |
| EAN13(DataToEncode) | DataToEncode is a number string of 12, 13, 14, 15, 17 or 18 digits with or without a check digit, add-ons are supported. Formats output to the UPC/EAN barcode font. Entering incorrect data will create a barcode containing all zeros. |
| EAN8(DataToEncode) | DataToEncode is a number string of 7 or 8 characters (EAN-8 without the check digit). Formats output to the UPC/EAN barcode font. Entering incorrect data will create a barcode containing all zeros. |
|
Visual Basic 6 Module Example: |
|
Visual Basic .NET Module Example: |


'Set the font of the font object and
the text to encode
PrintFont = New Font("IDAutomationHC39M", 12)
VariableToPrint = "*" & "12827384736388" & "*"
'Add an event handler that will be
called for each page that is generated
AddHandler PrintDoc.PrintPage, AddressOf Me.PrintDoPrintPage
'Initiate the printing of the
document
PrintDoc.Print()
'****
The following code should be placed in the event handler, which
places the data on the page:
Dim linesPerPage As Single = 0
'Number of lines (bar codes) that you will be able to fit on the page
Dim yPos As Single = 0
'yPos on the page of the bar code
Dim leftMargin As Single = ev.MarginBounds.Left 'left
margin of bar code
Dim topMargin As Single = ev.MarginBounds.Top 'top margin
of bar code
Dim line As String = Nothing
'String that font will be applied to and printed
|
Barcode ActiveX Control Integration with VB.NET |
The IDAutomation.com ActiveX controls allow generation of Windows Enhanced Metafile images and printing from Visual Studio.NET. IDAutomation recommends using .NET Forms Controls instead of ActiveX if possible.


Private Sub cmdPrintToPrinter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrintToPrinter.Click
Dim pd As New PrintDocument()
'Add an Event Handler for printing
AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
'Fire off the print page event.
pd.Print()
End Sub'Event handler for the PrintDocument
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
Dim linesPerPage As Single = 0
Dim yPos As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = ev.MarginBounds.Left 'Left Margin of Page
Dim topMargin As Single = ev.MarginBounds.Top 'Top Margin of Page.
Dim line As String = Nothing 'Data that we will write to the printer
' Calculate the number of lines per page based on the height of the font that was sent.
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
' Print each line of the file.
line = "IDAutomation.com, Inc. VB Dot Net Example"
'Set the y co-ordinate of where we are going to print the Line
yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
'Send the string to the printer
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())
'Increase the line count
count += 1
'Set the y position of the next line
yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
'Set the second string to be printed. We have to account for the actual printing position of the
'bar code when displaying yPos in this line. yPos set above is actually the location that this line
'will be printed on.
line = "Printing the Enhanced Metafile version of the barcode at X=" & leftMargin & ", Y=" & yPos + (topMargin + ((count + 1) * printFont.GetHeight(ev.Graphics)))
'Print the string
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())'Increase the line count
count += 1
'Increase the ypos
yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
'Print the enhanced metafile image of the bar code
ev.Graphics.DrawImage(AxBarCode1.GetEnhWMF, leftMargin, yPos)End Sub
An image may also be saved the a local hard drive with the following code:
Private Sub cmdSaveToFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSaveToFile.Click
AxBarCode1.SaveBarCode("C:\SavedBarCode.wmf")
End SubCopying the image to the clipboard is only supported with IDAutomation's .NET Forms Controls. When printing with Crystal Reports, refer to the Crystal Reports Integration Guide for the best implementation method.
|
|
|
Product Links: [Barcode Fonts | Barcode Components | Barcode Label Software | Barcode Scanners] |
© Copyright 2003-2007 IDAutomation.com, Inc., All Rights Reserved. Legal Notices.
|
Over 70% of Fortune 100 companies use our products to automate their businesses. |