We have been using this Mod10 code for years. Note - CLEN = LEN(CARD.NUM)

0076 **
0077 ** ================================================================
0078 **
0079 ALGO.CHECK:  ** card number algorithm check
0080  CSTR = "" ; PTR = 0
0081  FOR I = CLEN TO 1 STEP -1
0082   PTR = PTR + 1
0083   IF MOD(PTR, 2) # 0 THEN MULTI = 1 ELSE MULTI = 2
0084   CSTR = CARD.NUM[I, 1] * MULTI : CSTR
0085  NEXT I
0086  **
0087  CSUM = 0 ; CLEN = LEN(CSTR)
0088  FOR I = 1 TO CLEN
0089   CSUM += CSTR[I, 1]
0090  NEXT I
0091  **
0092  IF NOT((MOD(CSUM, 10) = 0)) THEN
0093   ERR = "Invalid card number."
0094  END
0095 RETURN

Robin Stanley

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Baker Hughes
Sent: Friday, December 02, 2005 8:11 AM
To: u2-users@listserver.u2ug.org
Subject: [U2] Mod10 Credit Card Checksum


Say, has anyone written some code to validate a Credit Card number,
using the Mod10 (nicknamed) or ANSI X4.13 (realname) LUHN formula?  I
was just told today get this installed yesterday, so I'm naturally
looking to see if some kind-hearted fellow MV'ver has something already
written (it is the season for giving ;-) ).

I searched ansi.org and only got hits on meeting agendas - [in session
4.13 discuss blah blah]
I found the previous u2ug posting that used Mod10 to validate a UPC, but
it looks a bit different from algorithm described elsewhere to validate
CCnumbers, and doesn't look agreeable to variable lengths (different you
know based on each card type).

I'm really thankful for U2UG, and glean much from the postings.  I'd
contribute more answers but I've only been at this 14 years and someone
more seasoned invariably gives a thoroughly enlightening response.

TIA.

-Baker
bakerdothughes
atmouser
dotcom
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to