If I come across stuff like the below that can just be cut and pasted onto the net, I'll try to do so.
Here is a piece of code that might be useful to someone googling for credit card validation. Enjoy.
'Credit Card Validation Routine (Visual Basic)
'
'Copyright (c) Bob Trower, 2001
'This source code may be used as you wish, provided
'that these comments remain in the code.
'
'Returns True if the card number is valid, False otherwise
'Algorithm is the 'LUHN' formula specified in ANSI X4.13
'Last Digit of Card Number is the 'check digit'.
'From right to left, take value of check digit and add:
' double every second number and sum resulting digits.
' add the non-doubled digits.
'If the Credit Card Number is valid, the final sum
'will be an even multiple of ten ((x mod 10) = 0 ).
Function IsValidCCNumber(CCNumber As String) As Integer
Dim CheckSum As Integer
Dim ThisDigit As Integer
Dim i As Integer
' Note: Order of Steps is important...
IsValidCCNumber = False ' Redundant in VB, but good practice
If Len(CCNumber) > 10 Then ' Known Card numbers are more than 10 digits long
CheckSum = Val(Mid(CCNumber, Len(CCNumber), 1)) 'Last Digit is CheckSum Digit
For i = Len(CCNumber) - 1 To 1 Step -2
ThisDigit = Val(Mid(CCNumber, i, 1)) * 2 ' Double these digits
CheckSum = CheckSum + (ThisDigit \ 10) + (ThisDigit Mod 10) ' Add the sum of the resulting digits
Next
For i = Len(CCNumber) - 2 To 1 Step -2
CheckSum = CheckSum + Val(Mid(CCNumber, i, 1)) ' Add these digits
Next
If CheckSum Mod 10 = 0 Then ' Resulting number should be an even multiple of 10
IsValidCCNumber = True
End If
End If
End Function
FOAF updates: Trust rankings are now exported, making the data available to other users and websites. An external FOAF URI has been added, allowing users to link to an additional FOAF file.
Keep up with the latest Advogato features by reading the Advogato status blog.
If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!