Important alert: (current site time 7/16/2013 4:15:02 AM EDT)
 

VB icon

Credit Card Checksum Checker

Email
Submitted on: 5/27/1998
By: John Anderson  
Level: Not Given
User Rating: By 3 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 37966
 
     Checks to see if a Credit Card Number is valid by performing the LUHN-10 check on it.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Credit Card Checksum Checker
' Description:Checks to see if a Credit Card Number is valid by performing the LUHN-10 check on it.
' By: John Anderson
'
' Inputs:CCNum as String
'
' Returns:True if Valid, False if Invalid
'
' Side Effects:May cause skin irritation
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=902&lngWId=1'for details.'**************************************

Public Function IsValidCCNum(CCNum As String) As Boolean
Dim i As Integer
Dim total As Integer
Dim TempMultiplier As String
For i = Len(CCNum) To 2 Step -2
total = total + CInt(Mid$(CCNum, i, 1))
TempMultiplier = CStr((Mid$(CCNum, i - 1, 1)) * 2)
total = total + CInt(Left$(TempMultiplier, 1))
If Len(TempMultiplier) > 1 Then total = total + CInt(Right$(TempMultiplier, 1))
Next
If Len(CCNum) Mod 2 = 1 Then total = total + CInt(Left$(CCNum, 1))
If total Mod 10 = 0 Then
IsValidCCNum = True
Else
IsValidCCNum = False
End If
End Function


Other 1 submission(s) by this author

 


Report Bad Submission
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:

Your Vote

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

Other User Comments
6/29/1999 8:26:00 AMfengbald

Nice routine will use it at work.
(If this comment was disrespectful, please report it.)

 
7/19/1999 3:08:00 PModeadendo

good idea
(If this comment was disrespectful, please report it.)

 
8/19/1999 11:00:00 AMblah

How do we use this?? I mean... how do I tell it what the CCNum is.. and when to check it?
(If this comment was disrespectful, please report it.)

 
9/5/1999 9:48:00 AMslackker

John would it be possible to know what the interface should be like or have on it to use this code? Thanks slackker
(If this comment was disrespectful, please report it.)

 
9/22/1999 10:05:00 AMFaisal

Thanx for the code. I was just wondering, won't it be dangerous to use this code to create valid credit card numbers? If so then you should prevent it somehow. Thanx again.
(If this comment was disrespectful, please report it.)

 
10/19/1999 9:55:00 AMKevin

Can you just paste this into a web page as VBScript?
(If this comment was disrespectful, please report it.)

 
10/27/1999 1:19:00 PMJP

wow... didn't knew CCChecksum was that easy ;)
(If this comment was disrespectful, please report it.)

 
11/21/1999 3:26:00 PMdynasty

any cc generater could outsmart this program.....no good... -=)
(If this comment was disrespectful, please report it.)

 
11/26/1999 8:21:00 PMUM

not nessisarily
(If this comment was disrespectful, please report it.)

 
12/28/1999 8:38:55 PMJohn Anderson

blah - CCNum should be a string containing the Credit Card number without spaces/dashes/etc. The routine returns True if Valid, False if not.

slackker - This was developed for use in an e-commerce solution. The best way to use this is to do a quick check for typos before submitting the card number to your processor.

Faisal - This checksum method is widely known. The only 100% secure way to verify a valid card number is through a credit card processor (i.e. Cybercash)

dynasty - You're right. But the odds of your CC Generator picking the number of a valid card are less than the odds of you winning the lottery. =)


(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.