- Home
·
- Miscellaneous
·
- Validates whether or not a given credit card number is valid based on the standard LUHN's Modulus 1
Validates whether or not a given credit card number is valid based on the standard LUHN's Modulus 1
Validates whether or not a given credit card number is valid based on the standard LUHN's Modulus 10 Algorithm
Rate Validates whether or not a given credit card number is valid based on the standard LUHN's Modulus 1
(2(2 Vote))
If Not IsNumeric(CardNumber) Then
ValidateCCNumber = False
Exit Function
End If
CardNumber = StrReverse(CardNumber)
For CycleDigits = 1 To Len(CardNumber)
CurrentDigit = Mid(CardNumber,CycleDigits,1)
If CycleDigits Mod 2 = 1 Then
LUHNTotal= LUHNTotal + CInt(CurrentDigit)
Else
CurrentDigit = CInt(CurrentDigit) * 2
If CurrentDigit < 10 Then
LUHNTotal= LUHNTotal+ CInt(CurrentDigit)
Else
LUHNTotal= LUHNTotal + CInt(Left(CurrentDigit,1)) + CInt(Right(CurrentDigit,1))
End If
End If
Next
If LUHNTotal Mod 10 = 0 Then
ValidateCCNumber = True
Else
ValidateCCNumber = False
End If
End Function
Validates whether or not a given credit card number is valid based on the standard LUHN's Modulus 1 Comments
No comments yet — be the first to post one!
Post a Comment