In this issue we discuss how use the LUHN credit card number validation formula. This is sometimes called the MOD 10 formula.
If you have any questions about using this module, let us know at questions@codeoftheweek.com
This module contains a single routine called CreditCardValidate that takes a string of digits, removes all characters other than numbers and performs the Luhn validation formula (mod 10 formula).
This algorithm works by doing the following:
If you had a number such as 372712312312345 the formula would calculate like this: 5+3+1+2+3+1+2+3 for the first step. The first part of the second step would be (4*2)+(2*2)+(3*2)+(1*2)+(2*2)+(7*2)+(7*2) which would result in the following additions 8+4+6+3+4+(14-9)+(14-9).
Public Function CreditCardValidate(sCardNumber As String) As Boolean
The sCardNumber is the full credit card number to validate. It can have spaces or dashes anyplace in the number.
Some examples are shown using different credit card numbers (NOTE: the credit card numbers are not real card numbers).
Debug.Print CreditCardValidate("4234123412341234") ' will print out as True (if the credit card was actually a real card number)
To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0119.html
If you would like to get paid for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html