The POSTNET (POSTal Numeric Encoding Technique) bar code type was developed by the U. S. Post Office to encode a delivery address, which can be one of three forms (1) 5-digit ZIP; (2) 5-digit ZIP+4 code and (3) 11-digit delivery point code. A valid POSTNET barcode comprises either 32 bars, 52 bars or 62 bars (including frame bars and check digit, see below).
POSTNET is a numeric symbology. Different from other symbologies, POSTNET is a height-modulated symbology which encodes the data in the height of the barcode instead of the width.
A POSTNET barcode consists of a starting frame bar, data digits, a check digit and a stopping frame bar, as illustrated above. Therefore, simplying formating the number with the font won't produce a valid barcode.
You can use either the asterisk *, vertical bar
symobl |, left or right
square brackets [ and ] for the
starting and ending frame bar. So if you know the check digit is
1
for zip code 91801, you can enter
[918011] and
format it with the font
mrvpostnet.sfp. To learn how to calculate the check digit,
scroll down to the next section.
The value of the check digit is that when added to the sum
of other digits in the barcode, results in a total that is multiple
of 10. For our sample zip code 91801, the check digit
is 1 since 9+1+8+0+1+1=20
which is two times of 10.
C Code
char zipcode[20], barcodestring[20];
char* p;
int sum, check_digit;
strcpy(zipcode, "918011234");
sum=0;
p=zipcode;
while (*p!=NULL) {
sum += *p-'0';
p++;
}
check_digit = 10 - (sum%10);
if (check_digit==10 ) check_digit=0;
printf("*%s%d*", zipcode, check_digit);
BASIC Code
Dim i As Integer
Dim charToEncode As String
Dim checkSum As Integer
Dim checkDigit As String
Dim strZipCode As String
strZipCode = "918011234";
For i = 1 To Len(inpara)
charToEncode = Mid(strZipCode, i, 1)
Postnet = Postnet + charToEncode
checkSum = checkSum + Val(charToEncode)
Next i
checkSum = checkSum Mod 10
If checkSum <> 0 Then checkSum = 10 - checkSum
checkDigit = Chr(checkSum + Asc("0"))
