Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Mod-7 check digit for barcoding
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00533810
Message ID:
00533814
Views:
28
>Does anyone have a routine for calculating mod-7 check digits for barcoding?
>
>Thanks
>
>
>Colin Northway

I have a function that create a checksum digit for customer numbers in our app, i think (not sure) the same methodology is used for bar coding.
Here it is:
FUNCTION CustNoCheckSum( cCustno ) 

	*-- Returns a 1 Char checksum for customer number
	LOCAL i, lcResult, lcString, lnResult
	lcResult = ""
	lnResult = 0 
	FOR i = 1 TO Len(Alltrim(cCustNo))
		IF ISALPHA( SubStr(cCustNo,i,1) ) 
			RETURN ""
		ENDIF
		lcResult = lcResult + IIF( MOD(i, 2) # 0, SubStr(cCustNo,i,1), ALLTRIM( STR(Val( SubStr(cCustNo,i,1)) * 2)) )
	EndFor
	FOR i = 1 TO LEN(lcResult) 
		lnResult = lnResult + VAL( Substr( lcResult,i,1 ) )
	ENDFOR

	RETURN AllTrim(Str(MOD(lnResult, 10)))

ENDFUNC
Previous
Reply
Map
View

Click here to load this message in the networking platform