That's handy! On a similar thread - does anyone have the algorithm for validating IRD numbers? I had it a few years ago and somehow lost it.
Bob Osborn ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> Sent: Thursday, October 17, 2002 4:10 PM Subject: RE: [DUG]: Detecting credit card type by card number > > Delphi function for LUHN checking. Note that this is ok for credit cards > but some types of Debit (EFTPOS) cards dont seem to use this standard! > > function CheckLuhn(const sEftCard: string): Boolean; > var > sCard: string; > i, iOddEven, iTot, iDigit: Integer; > begin > Result := True; > > try > if pos('=', sEftCard) = 0 then > sCard := sEftCard else > sCard := Copy(sEftCard, 1, pos('=', sEftCard) - 1); > iOddEven := 0; > iTot := 0; > for i := length(sCard) downto 1 do begin > iDigit := StrToInt(copy(sCard, i, 1)); > if iOddEven mod 2 <> 0 then begin > case iDigit of > 0: iDigit := 0; // 2*0=0 > 1: iDigit := 2; // 2*1=2 > 2: iDigit := 4; // 2*2=4 > 3: iDigit := 6; // 2*3=6 > 4: iDigit := 8; // 2*4=8 > 5: iDigit := 1; // 2*5=10 = 1+0 = 1 > 6: iDigit := 3; // 2*6=12 = 1+3 = 3 > 7: iDigit := 5; // 2*7=14 = 1+4 = 5 > 8: iDigit := 7; // 2*8=16 = 1+6 = 7 > 9: iDigit := 9; // 2*9=18 = 1+8 = 9 > end; > end; > Inc(iOddEven); > iTot := iTot + iDigit; > end; > Result := ((iTot mod 10) = 0); > except > Result := False; > end; > > > ############################################################################ ######### > This e-mail message has been scanned for Viruses and Content by both MailMarshal and > Norton's Antivirus. > > Attention: > The information contained in this message and or attachments is intended only for the > person or entity to which it is addressed and may contain confidential and/or privileged > material. Any review, retransmission, dissemination or other use of, or taking of any > action in reliance upon, this information by persons or entities other than the intended > recipient is prohibited. If you received this in error, please contact the sender and > delete the material from any system and destroy any copies. > > Please note that the views and opinions expressed in this message may be those > of the individual and not necessarily those of Foodstuffs (South Island) Ltd > ############################################################################ ######### > 5y-R2:-.u?-"M2?A&.NJzT62.-"O.Jz1m-Yf@-Hb=f-?[i|0Bf".*\?+^r??uii?.4uii?*+, | --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/