I am trying to write a function in VB 4 which takes a credit card number and returns...

* Whether the card number is valid or not.

* The type of credit card (Visa, MasterCard, Discover, American Express etc).

I know there is a mathematical algorithm which can check for valid credit card number patterns. Can anyone provide me with a routine which does the above and/or an algorithm to do this please? I think that the card type can easily be detected by looking at the first digit of a credit card number, but which value represents which card type?

* Whether the card number is valid or not.

* The type of credit card (Visa, MasterCard, Discover, American Express etc).

I know there is a mathematical algorithm which can check for valid credit card number patterns. Can anyone provide me with a routine which does the above and/or an algorithm to do this please? I think that the card type can easily be detected by looking at the first digit of a credit card number, but which value represents which card type?

If you need this for a commercial application, there's an OCX control for credit card validation and even charging amounts to it. I don't remember of hand, but the ad for it has been in every issue of VB programmer's journal since about two years ago.

I used to have some info on this (I quoted sucha project a long time ago), I'll try to find it.

4 - Discover

5 - Mastercard

.

We're using a product called PC-Charge with VB. It's an ActiveX OCX that performs credit card transactions, credit card number validation....

Go Software, Inc.

42 W. Montgomery Crossroad, Suite O

Savanna, GA 31406

(912) 925-4048

When I originally posted that there were different multipliers, I was only half right. The actual multipliers are different for some cards, but only because the cards have different digit lengths. However, the algorithm used to generate the multiplier is the same for all cards: the rightmost digit is a 1, the next digit to the left is 2, and then the digits alternate. For example, Amex is 121212121212121 and Mastercard is 2121212121212121.

The original reason for the check digit was to cheaply catch simple manual entry errors, such as a single digit entered incorrectly and two adjacent digits transposed. The alternating 1-2 multiplier does a decent job of that.

Hope this helps!

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.