VB icon

Credit Card Identification

Email
Submitted on: 1/1/2015 3:03:00 PM
By: John Anderson (from psc cd)  
Level: Not Given
User Rating: By 2 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 1100
 
     Determines type of Credit Card by it's number.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Credit Card Identification
' Description:Determines type of Credit Card by it's number.
' By: John Anderson (from psc cd)
'
' Inputs:Card Number as String
'
' Returns:Card Type as String
'
' Assumes:This is based on documents from CyberCash's home page.
'
' Side Effects:Is not Year 2061 Compliant
'**************************************

Public Function CardType(CCNum As String) As String
Dim Header As String
Select Case Left$(CCNum, 1)
Case "5"
Header = Left$(CCNum, 2)
If Header >= 51 And Header <= 55 And Len(CCNum) = 16 Then
CardType = "MasterCard"
End If
Case "4"
If Len(CCNum) = 13 Or Len(CCNum) = 16 Then
CardType = "Visa"
End If
Case "3"
Header = Left$(CCNum, 3)
If Header >= 340 And Header <= 379 And Len(CCNum) = 15 Then
CardType = "AMEX"
End If
If Header >= 300 And Header <= 305 And Len(CCNum) = 14 Then
CardType = "Diners Club"
End If
If Header >= 360 And Header <= 369 And Len(CCNum) = 14 Then
CardType = "Diners Club"
End If
If Header >= 380 And Header <= 389 And Len(CCNum) = 14 Then
CardType = "Diners Club"
End If
If Header >= 300 And Header <= 399 And Len(CCNum) = 16 Then
CardType = "JCB"
End If
Case "6"
Header = Left$(CCNum, 4)
If Header = "6011" And Len(CCNum) = 16 Then
CardType = "Discover"
End If
Case "2"
Header = Left$(CCNum, 4)
If (Header = "2014" Or Header = "2149") And Len(CCNum) = 15 Then
CardType = "enRoute"
End If
If Header = "2131" And Len(CCNum) = 15 Then
CardType = "JCB"
End If
Case "1"
Header = Left$(CCNum, 4)
If Header = "1800" And Len(CCNum) = 15 Then
CardType = "JCB"
End If
End Select
If CardType = "" Then CardType = "Unknown"
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


 There are no comments on this submission.
 

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.