VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Find out from a given credit card number what type of card this is associated with eg Visa/MasterCa

by Roderick Thompson (12 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Thu 1st February 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Find out from a given credit card number what type of card this is associated with eg Visa/MasterCard etc.

Rate Find out from a given credit card number what type of card this is associated with eg Visa/MasterCa



CardLength = Len(CardNumber)
If CardLength = 16 Then
If Left(CardNumber,1) = "5" Then
If CInt(Mid(CardNumber,2,1)) >= 1 And CInt(Mid(CardNumber,2,1)) <= 5 Then
CheckCardType = "MasterCard"
End If
  ElseIf Left(CardNumber,1) = "4" Then
CheckCardType = "VISA"
  ElseIf Left(CardNumber,1) = "3" Then
CheckCardType = "JCB"
ElseIf Left(CardNumber,4) = "6011" Then
CheckCardType = "Discover"
End If 
ElseIf CardLength = 15 Then
If Left(CardNumber,2) = "34" Or Left(CardNumber,2) = "37" Then
CheckCardType = "AMEX"
ElseIf Left(CardNumber,4) = "2014" Or Left(CardNumber,4) = "2149" Then
CheckCardType = "enRoute"
ElseIf Left(CardNumber,4) = "2131" Or Left(CardNumber,4) = "1800" Then
CheckCardType = "JCB"
End If
ElseIf CardLength = 14 Then
If Left(CardNumber,2) = "30" Then
If CInt(Mid(CardNumber,3,1)) >= 1 And CInt(Mid(CardNumber,3,1)) <= 5 Then
CheckCardType = "Diners Club"
End If
ElseIf Left(CardNumber,2) = "36" Or Left(CardNumber,2) = "38" Then
CheckCardType = "Diners Club"
End If
ElseIf CardLength = 13 Then
If Left(CardNumber,1) = "4" Then CheckCardType = "VISA"
Else
CheckCardType = "UNKNOWN"
End If
If CheckCardType = "" Then CheckCardType = "UNKNOWN"
End Function

Download this snippet    Add to My Saved Code

Find out from a given credit card number what type of card this is associated with eg Visa/MasterCa Comments

No comments have been posted about Find out from a given credit card number what type of card this is associated with eg Visa/MasterCa. Why not be the first to post a comment about Find out from a given credit card number what type of card this is associated with eg Visa/MasterCa.

Post your comment

Subject:
Message:
0/1000 characters