This site will look much better in a browser that supports web standards, but it is accessible to any browser or Internet device.
The following functions can be used within Microsoft Visual Basic to create and print POSTNET barcodes using Azalea Software's barcode fonts. Other functions are available for UPC, Code 128, Code 39, and Interleaved 2 of 5.
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.
Dim yourString as String
If Not IsNumeric(yourSring) Then
' error handling
End If
If Len(yourString) <> 5 And Len(yourString) <> 10 And Len(yourString) <> 13 Then
' the ZIP code input must be 5-, 9- or 11-digits
Exit Sub
End If
' strip the hyphen and space if need be. "12345-6789" to "123456789" or "12345-6789 00" to "12345678900"
Select Case Len(yourString)
Case 13
yourString = Left$(theZIP, 5) & Mid$(theZIP, 7, 4) & Right$(theZIP, 2)
Case 10
yourString = Left$(theZIP, 5) & Right$(theZIP, 4)
End Select
To do a POSTNET bar code:
Function AzaleaPOSTNET(ByVal theZIP as String) as String
' POSTools v5.0 4.14.99
' Copyright 2002 Jerry Whiting. All rights reserved.
' Azalea Software, Inc. www.azalea.com
' The input, theZip, is a string for the ZIP code.
' The input should be all numbers, no hyphens or spaces. "12345", "123456789", or "12345678900"
' Format the output, AzaleaPOSTNET, using Azalea's POSTNET font.
Dim theZIP As String
Dim i As Integer ' loop counter
Dim checkDigit As Integer ' check digit variable
' set up variable
checkDigit = 0
' build check sum subtotal
For i = 1 To Len(theZIP)
checkDigit = checkDigit + Val(Mid(theZIP, i, 1))
Next i
' POSTNET check digit is the single digit, that when added to the
' total of all the ZIP code's digits, makes the next multiple of 10.
' Concantenate the start bar, the ZIP code, check digit, & the stop bar.
' Format the output, AzaleaPOSTNET, using Azalea Software's POSTNET font.
AzaleaPOSTNET = "s" + theZIP + Right(Str(100 - checkDigit), 1) + "s"
' yourContainer.text = AzaleaPOSTNET(yourString)
End Function