Azalea Software, Inc. www.azalea.com Print Code 39 Barcodes in Visual Basic Code39 in VB

Print barcodes in Visual Basic programs using Azalea Software's barcode fonts. We've already written functions that generate Code 39 barcodes in VB programs.

Visual Basic functions:
    Code 39  •  Code 39 Full ASCII  •  Code 39 check digit


Function Azalea_Code_39(ByVal Code39 As String) As String
' C39Tools 24mar09 jwhiting
' Copyright 2009 Azalea Software, Inc. All rights reserved. www.azalea.com
' Creating a Code 39 barcode in Excel
' Your input, Code39, is a string to be encoded as a Code 39 symbol.
' yourData must be the Code 39 character set. Input error checking is your responsibility.
' The standard Code 39 character set is: A-Z (upppercase), 0-9, $ % + - . / and the space character.
  Dim i As Integer ' our loop counter
  Dim chunk As String ' loop chunk
  Dim temp As String ' a temporary placeholder
  ' TrueType doesn't support glyphs in the space slot (ASCII 32)
  ' We've moved the space character to the underscore ( _ ).
  ' Therefore "APPLE PIE" is formatted as *APPLE_PIE*
  ' Here's the search and replace, underscore for space:
  For i = 1 To Len(Code39)
    chunk$ = Mid$(Code39, i, 1)
    If chunk = " " Then
      temp = temp + "_"
    Else
      temp = temp + chunk
    End If
  Next i
  ' Add the start and stop bars, the asterisk, before and after the input string.
  Azalea_Code_39 = "*" + temp + "*"
  ' Excel: B1=Azalea_Code_39(A1)
  ' Or put another way, yourContainer.text=Azalea_Code_39(yourInputString)
End Function

You may port these functions to other languages and development tools, so feel free to copy, paste, and edit the code as needed; our sole caveat is that our copyright notice must remain intact. When you port, or if you find a bug or something that needs improvement, please send us a copy so we can learn something new. (Our email address is technicalsupport at azalea dot com …and as always, AtDhVaAnNkCsE!)