ActiveX: SLCreditCard (Filename: SLCRCARD.OCX)
![]()
| SLCreditCard is an ActiveX control that can be used to validate credit card numbers and check expiration dates of a credit cards. The control can also determine the type of credit card by examining the credit card number. The control recognizes the following four card types: VISA, American Express, MasterCard and Discover. But the control can also make a general credit card number check and expiration date check 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 (checking 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/99" (same as December 1999). |
| 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 IsNumberValid
() As Boolean IsValid
() As Boolean |
Example
Dim X As Long
SLCreditCard1.Number = "4111 1111 1111 1111"
SLCreditCard1.ExpirationDate = "01/04"
SLCreditCard1.CardType = 1 ' VISA
X = CC_OK
' Check credit card number
If SLCreditCard1.IsNumberValid() = False Then
X = CC_INVALID_NUMBER
GoTo FX
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
FX:
![]()