0% found this document useful (0 votes)
53 views4 pages

IDAutomation Postnet Function MAC

Uploaded by

Ras Rio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views4 pages

IDAutomation Postnet Function MAC

Uploaded by

Ras Rio
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 4

'*****************************************************************

' Visual Basic & VBA Functions for IDAutomation Barcode Fonts 8.0
' © Copyright, 2000-2008 IDAutomation.com, Inc. All rights reserved.
' Redistribution and use of this code in source and/or binary
' forms, with or without modification, are permitted provided
' that: (1) all copies of the source code retain the above
' unmodified copyright notice and this entire unmodified
' section of text, (2) You or Your organization owns a valid
' Developer License to this product from IDAutomation.com
' and, (3) when any portion of this code is bundled in any
' form with an application, a valid notice must be provided
' within the user documentation, start-up screen or in the
' help-about section of the application that specifies
' IDAutomation.com as the provider of the Software bundled
' with the application.
'*****************************************************************

Dim I As Integer
Dim J As Integer
Dim F As Integer
Dim DataToPrint As String
Dim OnlyCorrectData As String
Dim PrintableString As String
Dim WeightedTotal As Long
Dim CheckDigitValue As Integer
Dim Factor As Integer
Dim CheckDigit As Integer
Dim HumanReadableText As String
Dim StringLength As Integer
'The DLL referenced below may be downloaded from
www.idautomation.com/fonts/tools/windows_dll/
'and is only required to create USPS Intelligent Mail symbols. It is not required for other
barcode types.
'The file is free to use and distribute with this module, provided You or Your organization
'owns a valid Developer License for the associated IDAutomation product or Barcode
Font.
Public Declare Function IDAutomation_Universal_OneCode _
Lib "IDAutomationNativeFontEncoder.dll" _
(ByVal D2E As String, _
ByVal out As String, _
ByRef iSize As Long) As Long
'END OF DECLARACTIONS

Public Function Postnet(DataToEncode As String, ReturnType As Integer) As String


'Additional logic in case ReturnType is not correct
If ReturnType <> 0 And ReturnType <> 1 And ReturnType <> 2 Then ReturnType = 0
DataToPrint = ""
OnlyCorrectData = ""
'Check to make sure data is numeric and remove dashes, etc.
StringLength = Len(DataToEncode)
For I = 1 To StringLength
'Add all numbers to OnlyCorrectData string
'2006.2 BDA modified the next 3 lines for compatibility with different office
versions
'If IsNumeric(Mid(DataToEncode, I, 1)) Then OnlyCorrectData = OnlyCorrectData
& Mid(DataToEncode, I, 1)
CurrentCharNum = AscW(Mid(DataToEncode, I, 1))
If CurrentCharNum > 47 And CurrentCharNum < 58 Then OnlyCorrectData =
OnlyCorrectData & Mid(DataToEncode, I, 1)
Next I
DataToEncode = OnlyCorrectData
'Calculate Check Digit
WeightedTotal = 0
StringLength = Len(DataToEncode)
For I = 1 To StringLength
'Get the value of each number
CurrentCharNum = Mid(DataToEncode, I, 1)
'Add the values together
WeightedTotal = WeightedTotal + CurrentCharNum
Next I
'Find the CheckDigit by finding the number + WeightedTotal that = a multiple of 10
'divide by 10, get the remainder and subtract from 10
I = (WeightedTotal Mod 10)
If I <> 0 Then
CheckDigit = (10 - I)
Else
CheckDigit = 0
End If
'ReturnType 0 returns data formatted to the barcode font
If ReturnType = 0 Then Postnet = "(" & DataToEncode & CheckDigit & ")"
'ReturnType 1 returns data formatted for human readable text
If ReturnType = 1 Then Postnet = DataToEncode & CheckDigit
'ReturnType 2 returns the check digit for the data supplied
If ReturnType = 2 Then Postnet = Str$(CheckDigit)
End Function

Public Function MOD10(M10NumberData As String) As Integer


'***********************************************************************
' This is a general MOD10 function compatible with EAN and UPC standards
'***********************************************************************
Dim M10StringLength As Integer
Dim M10OnlyCorrectData As String
Dim M10Factor As Integer
Dim M10WeightedTotal As Integer
Dim M10CheckDigit As Integer
Dim M10I As Integer
M10OnlyCorrectData = ""
M10StringLength = Len(M10NumberData)
'Check to make sure data is numeric and remove dashes, etc.
For M10I = 1 To M10StringLength
'Add all numbers to OnlyCorrectData string
'2006.2 BDA modified the next 2 lines for compatibility with different office
versions
CurrentCharNum = AscW(Mid(M10NumberData, M10I, 1))
If CurrentCharNum > 47 And CurrentCharNum < 58 Then M10OnlyCorrectData =
M10OnlyCorrectData & Mid(M10NumberData, M10I, 1)
Next M10I
'Generate MOD 10 check digit
M10Factor = 3
M10WeightedTotal = 0
M10StringLength = Len(M10NumberData)
For M10I = M10StringLength To 1 Step -1
'Get the value of each number starting at the end
'CurrentCharNum = Mid(M10NumberData, I, 1)
'Multiply by the weighting factor which is 3,1,3,1...
'and add the sum together
M10WeightedTotal = M10WeightedTotal + (Val(Mid(M10NumberData, M10I, 1))
* M10Factor)
'Change factor for next calculation
M10Factor = 4 - M10Factor
Next M10I
'Find the CheckDigit by finding the smallest number that = a multiple of 10
M10I = (M10WeightedTotal Mod 10)
If M10I <> 0 Then
M10CheckDigit = (10 - M10I)
Else
M10CheckDigit = 0
End If
MOD10 = Str(M10CheckDigit)
End Function

'*****************************************************************
' © Copyright, IDAutomation.com, Inc. All rights reserved.
' Redistribution and use of this code in source and/or binary
' forms, with or without modification, are permitted provided
' that: (1) all copies of the source code retain the above
' unmodified copyright notice and this entire unmodified
' section of text, (2) You or Your organization owns a valid
' Developer License to this product from IDAutomation.com
' and, (3) when any portion of this code is bundled in any
' form with an application, a valid notice must be provided
' within the user documentation, start-up screen or in the
' help-about section of the application that specifies
' IDAutomation.com as the provider of the Software bundled
' with the application.
'*****************************************************************

' Internal Version 2008.01.04

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy