Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Luhn Check: Is the credit card number you are a...
Author:
Gabe Harris
E-mail:
Click to e-mail author
Submitted:
8/2/2000
Version:
VB6
Compatibility:
VB6
Category:
Views:
11758
Luhn Check: Is the credit card number you are accpeting a Valid #? if the function returns a 1 then the # is Luhn 10 valid...if it returns a 0 then the CC# is not valid.
Declarations:
'none
Code:
' the Luhn function need isodd() and ismodten() in 'order to work Function IsOdd(x) If Right(x, 1) = 1 Or Right(x, 1) = 3 Or Right(x, 1) = 5 Or Right(x, 1) = 7 Or Right(x, 1) = 9 Then IsOdd = 1 Else IsOdd = 0 End If End Function 'Line9 Function IsModTen(x) If Right(Trim(x), 1) = 0 Then IsModTen = 1 Else IsModTen = 0 End If End Function 'Line18 'this is Function LUHN(x) temp = 0 a = 0 i = 0 l = Len(x) For i = 1 To l a = Mid(x, l + 1 - i, 1) If IsOdd(i) = 1 Then temp = temp + a Else a = 2 * a If a > 9 Then a = Left(a, 1) + Right(a, 1) End If temp = temp + a End If Next i If IsModTen(temp) = 1 Then LUHN = 1 Else LUHN = 0 End If End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement