a Credit Card Number validation
Ever need to see if a credit card number is valid? Well, here is your chance. I did NOT write this code, I found it on the web!! Also, this may tell you if a number is valid, not if it works
Rate a Credit Card Number validation
(3(3 Vote))
Function CheckCard(CCNumber As String) As Boolean
Dim Counter As Integer, TmpInt As Integer
Dim Answer As Integer
Counter = 1
TmpInt = 0
While Counter <= Len(CCNumber)
If (Len(CCNumber) Mod 2) Then
TmpInt = Val(Mid$(CCNumber, Counter, 1))
If Not (Counter Mod 2) Then
TmpInt = TmpInt * 2
If TmpInt > 9 Then TmpInt = TmpInt - 9
End If
Answer = Answer + TmpInt
Counter = Counter + 1
Else
TmpInt = Val(Mid$(CCNumber, Counter, 1))
If (Counter Mod 2) Then
TmpInt = TmpInt * 2
If TmpInt > 9 Then TmpInt = TmpInt - 9
End If
Answer = Answer + TmpInt
Counter = Counter + 1
End If
Wend
Answer = Answer Mod 10
If Answer = 0 Then CheckCard = True
End Function
a Credit Card Number validation Comments
No comments yet — be the first to post one!
Post a Comment