by GAUTAM (1 Submission)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 11th January 2002
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
THIS PROGRAM DETERMINES THE TYPE OF CREDIT CARD ie: MASTER,VISA,AMERICAN,DISCOVER,etc ON THE BASIS OF THE CREDIT CARD NUMBER WHICH HAS TO BE
API Declarations
'DRAW A COMMAND BUTTON ON Form1
'*CARD TYPES *PREFIX *WIDTH
'American Express 34, 37 15
'Diners Club 300 to 305, 36 14
'Carte Blanche 38 14
'Discover 6011 16
'EnRoute 2014, 2149 15
'JCB 3 16
'JCB 2131, 1800 15
'Master Card 51 to 55 16
'Visa 4 13, 16
'Just in case nothing is found
CreditCardType = "Unknown Credit Card"
'Remove all spaces and dashes from the passed string
CardNo = Replace(Replace(CardNo, " ", ""), "-", "")
'Check that the minimum length of the string isn't less
'than fourteen characters and -is- numeric
If Len(CardNo) < 14 Or Not IsNumeric(CardNo) Then Exit Function
'Check the first two digits first
Select Case CInt(Left(CardNo, 2))
Case 34, 37
CreditCardType = "American Express"
Case 36
CreditCardType = "Diners Club"
Case 38
CreditCardType = "Carte Blanche"
Case 51 To 55
CreditCardType = "This is a Master Credit Card Number."
Case Else
'None of the above - so check the
'first four digits collectively
Select Case CInt(Left(CardNo, 4))
Case 2014, 2149
CreditCardType = "EnRoute"
Case 2131, 1800
CreditCardType = "JCB"
Case 6011
CreditCardType = "Discover"
Case Else
'None of the above - so check the
'first three digits collectively
Select Case CInt(Left(CardNo, 3))
Case 300 To 305
CreditCardType = "American Diners Club"
Case Else
'None of the above -
'so simply check the first digit
Select Case CInt(Left(CardNo, 1))
Case 3
CreditCardType = "JCB"
Case 4
CreditCardType = "This is a Visa Credit Card Number."
End Select
End Select
End Select
End Select
End Function
Private Sub Command1_Click()
MsgBox CreditCardType("5404607010803842") 'THE CREDIT CARD NUMBER HAS TO BE
PASSED AS AN ARGUMENT AS SHOWN ABOVE.
End Sub
No comments have been posted about THIS PROGRAM DETERMINES THE TYPE OF CREDIT CARD ie: MASTER,VISA,AMERICAN,DISCOVER,etc ON THE BASIS . Why not be the first to post a comment about THIS PROGRAM DETERMINES THE TYPE OF CREDIT CARD ie: MASTER,VISA,AMERICAN,DISCOVER,etc ON THE BASIS .