Azalea Software, Inc. www.azalea.com Print POSTNET Barcodes in Visual Basic POSTNET in VB

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

Visual Basic functions:
    POSTNET

Function Azalea_POSTNET(ByVal ZIPcode As String) As String
' POSTools 25mar09 jwhiting
' Copyright 2009 Azalea Software, Inc. All rights reserved. www.azalea.com
' Creating a POSTNET barcode in Excel
' ZIPcode, is a 5-digit ZIP code, a 9-digit ZIP+4, or an 11-digit Delivery Point Barcode to be encoded as a POSTNET symbol.
  ' one way to groom ZIPcode is to reject anything that isn't the correct length
  ' embedded hyphens and spaces will trigger this (98126-2398 for instance)
  ' If Len(ZIPcode) <> 5 And Len(ZIPcode) <> 10 And Len(ZIPcode) <> 13 Then
  ' Exit Function
  ' End If
  ' stored ZIP codes usually contain embedded hyphens and spaces that need to be elminiated
  ' "12345-6789" becomes "123456789" and "12345-6789 00" becomes "12345678900"
  Select Case Len(ZIPcode)
    Case 13
      ZIPcode = Left$(ZIPcode, 5) & Mid$(ZIPcode, 7, 4) & Right$(ZIPcode, 2)
    Case 10
      ZIPcode = Left$(ZIPcode, 5) & Right$(ZIPcode, 4)
  End Select
  Dim i As Integer ' our loop counter
  Dim checkDigit As Integer ' the check digit variable
  checkDigit = 0
  For i = 1 To Len(ZIPcode)
    checkDigit = checkDigit + Val(Mid(ZIPcode, i, 1))
  Next i
  ' Concantenate the start bar, the ZIP code, the check digit, & the stop bar.
  Azalea_POSTNET = "s" + ZIPcode + Right(Str(100 - checkDigit), 1) + "s"
  ' Excel: B1=Azalea_POSTNET(A1)
  ' Or put another way, yourContainer.text=Azalea_POSTNET(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!)