This site will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device.

bar code software

Azalea Software, Inc.


Printing Interleaved 2 of 5 Bar Codes in Visual Basic

The following functions can be used within Microsoft Visual Basic to create and print Interleaved 2 of 5 barcodes using Azalea Software's barcode fonts. Other functions are available for UPC, EAN, Code 39, and Code 128.

These functions can be ported to other languages and development tools. Copy, paste, and edit the code as needed. Our copyright notice must remain intact. When you port, please send us a copy so we can learn something new. AtDhVaAnNkCsE

This sample code is provided as is. While every attempt has been made to insure that it works correctly, please double-check it against the results obtained from our bundled wizard utility. Please report any bugs or problems.

Module I2of5
Function AzaleaI2of5(ByVal I2of5number As String) As String
' I2of5Tools v5.0 27nov06 jwhiting
' Copyright 2006 Jerry Whiting. All rights reserved. www.azalea.com
' $LastChangedDate: 2006-10-16 14:51:14 -0700 (Mon, 16 Oct 2006) $
' $LastChangedRevision: 41 $
  ' The input, I2of5number, is a numbers-only string.
  ' Format the output, AzaleaI2of5, using Azalea's Interleaved 2 of 5 fonts.
  Dim i As Integer
  Dim temp As String
  Dim temp2 As String  ' placeholder
  Dim chunk As String  ' placeholder
  If Len(I2of5number) Mod 2 <> 0 Then  ' if the input has odd number of digits
    I2of5number = "0" + I2of5number    ' pad it with a leading zero
  End If
  temp2 = I2of5number  ' divide input into pairs of digits
  For i = 1 To Len(I2of5number) / 2
    chunk = Left(temp2, 2)     ' grab 2 characters
    If Val(chunk) < 90 Then    ' offset into fonts' character set
      temp = temp + Chr(Val(chunk) + 33)
    ElseIf Val(chunk) = 90 Then
       temp = temp + Chr(182)
    ElseIf Val(chunk) = 91 Then
       temp = temp + Chr(183)
    ElseIf Val(chunk) > 91 Then
       temp = temp + Chr(Val(chunk) + 104)
    End If
    temp2 = Right(temp2, Len(temp2) - 2)  ' move to the next two characters
  Next i
  ' add the start and stop bars (ASCII 171 & ASCII 172)
  AzaleaI2of5 = Chr(171) + temp + Chr(172)
  ' Format the output, AzaleaI2of5, using Azalea Software's Interleaved 2 of 5 font.
  ' yourContainer.text = AzaleaI2of5(yourString)
End Function
End Module


contact ustechnical supportabout usour blogsite mapmisc.links