# a Credit Card Number validation

Email
 Submitted on: 1/4/2015 10:56:00 PM By: Dustin Davis (from psc cd) Level: Intermediate User Rating: By 3 Users Compatibility: VB 5.0, VB 6.0 Views: 3064

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

code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 ``` '************************************** ' Name: a Credit Card Number validation ' Description: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 ' By: Dustin Davis (from psc cd) '************************************** 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 ```

Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)