SamLogic Internet Components - Home
ActiveX: SLCreditCard      (Filename: SLCRCARD.OCX)


SLCreditCard is an ActiveX component that can be used to validate credit card numbers and check expiration dates of credit cards. The component can also determine the type of credit card by examining the credit card number. The component recognizes the following four card types: VISA, American Express, MasterCard and Discover. But the component can also make a general credit card number check and check expiration date to other credit card types.
 
 
Properties
 
Name Type Description
CardType Long Specifies the type of credit card. Can be one of the following:

0 - No specification of the card type
1 - VISA
2 - American Express
3 - MasterCard
4 - Discover

You can use the DetermineCardType method to obtain the card type if it not known. If you set this property to 0 before you make a validation of the card number, the control will only make a general check of the number (check that the last control number is correct).
 
ExpirationDate String Specifies the expiration date of the credit card. Must be in the format "mm/yy", for example "12/09" (same as December 2009).
 
Number String Specifies the credit card number. Space characters are allowed. Example:
"4111 1111 1111 1111".
 
     
 
 
Methods
 

CheckExpirationDate () As Long

Checks the expiration date of the credit card. You specify an expiration date via the ExpirationDate property and you can use this method to check that the credit card is not out of date. This method returns one of the following values:

1 = The credit card is valid, it's not out of date yet.
0 = The credit card is not valid anymore, it's out of date.
-1 = The specified date is not correct.
 

DetermineCardType () As Long

Determines the type of the credit card. Returns one of the following values:

1 = VISA
2 = American Express
3 = MasterCard
4 = Discover

99 = Can't determine the card type
-1 = The credit card number is not correct

IsNumberValid () As Boolean

Checks that the credit card number is valid. You specify a card number via the Number property and you can use this method to check that the number is valid. If the number is correct this method returns True, otherwise it returns False.

IsValid () As Boolean

Checks that the credit card is valid. This method checks both credit card number and expiration date. It also takes into consideration the credit card type you specified via the CardType property. If any condition is False, this method returns False. If the credit card is valid this method returns True.  
 

 
 
Example
 
Dim X As Long
SLCreditCard1.Number = "4111 1111 1111 1111"
SLCreditCard1.ExpirationDate = "01/09"
SLCreditCard1.CardType = 1
' VISA
X = CC_OK
 
' Check credit card number
If SLCreditCard1.IsNumberValid() = False Then
    X = CC_INVALID_NUMBER
    GoTo ERR_INVALID
End If
 
' Check expiration date
If SLCreditCard1.CheckExpirationDate() <> 1 Then
    If SLCreditCard1.CheckExpirationDate() = 0 Then
        X = CC_OUTOFDATE
    Else
        X = CC_ILLEGAL_DATE
    End If
End If
 
ERR_INVALID:
 
 
 
< Go back
 
 
SamLogic