VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Validates whether or not a given credit card number is valid based on the standard LUHN's Modulus 1

by Roderick Thompson (12 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Thu 1st February 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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



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

Download this snippet    Add to My Saved Code

Validates whether or not a given credit card number is valid based on the standard LUHN's Modulus 1 Comments

No comments have been posted about Validates whether or not a given credit card number is valid based on the standard LUHN's Modulus 1. Why not be the first to post a comment about Validates whether or not a given credit card number is valid based on the standard LUHN's Modulus 1.

Post your comment

Subject:
Message:
0/1000 characters