Manage Learn to apply best practices and optimize your operations.

# Validating Credit Card Numbers

## The following function validates credit card numbers.

This Content Component encountered an error
The following function validates credit card numbers. If the number is in a valid format, the function returns "True"; if the number is in an invalid format, it returns "False". This algorithm should work with all credit cards. If the function validates a card, it doesn't mean the card is actually good, it means only that the numbers are arranged in a valid format. If a card isn't validated, you've saved some card-processing time. You can easily use this function in Common Gateway Interface (CGI) forms that process credit card orders.
```Function CheckCard(CCNumber As String) As Boolean
Dim Counter As Integer, TmpInt As Integer
Dim Answer As Integer

Counter = 1
TmpInt = 0

While Counter <= Len(CCNumber)
If IsEven(Len(CCNumber)) Then
TmpInt = Val(Mid\$(CCNumber, Counter, 1))
If Not IsEven(Counter) Then
TmpInt = TmpInt * 2
If TmpInt > 9 Then TmpInt = TmpInt - 9
End If
Answer = Answer + TmpInt
'Debug.Print Counter, TmpInt, Answer
Counter = Counter + 1
Else
TmpInt = Val(Mid\$(CCNumber, Counter, 1))
If IsEven(Counter) Then
TmpInt = TmpInt * 2
If TmpInt > 9 Then TmpInt = TmpInt - 9
End If
Answer = Answer + TmpInt
'Debug.Print Counter, TmpInt, Answer
Counter = Counter + 1
End If
Wend

Answer = Answer Mod 10

If Answer = 0 Then CheckCard = True
End Function
```
This was last published in August 2001

#### Start the conversation

Send me notifications when other members comment.

## SearchWindowsServer

• ### Roll your own Windows patching tool with PowerShell

This tutorial based on PowerShell helps administrators build an automated routine that audits Windows machines, then applies ...

• ### Server Core management remains a challenge for some

Server Core, the minimal Windows Server deployment, removes some admins from their GUI comfort zone, but its benefits reduce some...

• ### Meltdown and Spectre vulnerabilities dominate January Patch Tuesday

Complications surrounding the fix for the Meltdown and Spectre microprocessor architecture flaws will make the patching process ...

## Search400

• ### iSeries tutorials

Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

• ### V6R1 upgrade planning checklist

When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

• ### Connecting multiple iSeries systems through DDM

Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

## SearchDataCenter

• ### Three requirements for a hybrid cloud computing deployment

As the hybrid cloud computing approach gains steam, organizations will need to pay close attention to cross-cloud connectivity ...

• ### Five debunked myths about SSD issues

Solid-state drives are mature now, and the technology has eclipsed hard disk drives with superior performance, manageability and ...

• ### Future data center trends hinge on the edge, cloud and staffing

Edge computing, colocation, cloud and IT staffing issues lead the way as industry analysts make their predictions for the future ...

## SearchExchange

• ### Compliance Manager tool aims to ease security audit process

Administrators who wrestle with compliance tasks in Office 365 and Azure workloads might find some relief with Microsoft's ...

• ### Set Office 365 group limits to avoid administrative hassles

With help from PowerShell, administrators can tailor Office 365 Groups to develop common-sense restrictions on the tools and ...

• ### The top Exchange and Office 365 tutorials of 2017

Exchange Server remains a solid messaging choice, but interest in Microsoft's cloud platform shows no sign of abating. These ...

## SearchContentManagement

• ### Intelligent information management the next wave for ECM

In a 2018 upgrade, M-Files allows users to search for content in multiple repositories, while also being able to automatically ...

• ### SharePoint integration and implementation best practices

Here are some expert advice and tips, as well common definitions, to help make your SharePoint integration and implementation a ...

• ### SharePoint branding capabilities get a facelift

Since Microsoft Ignite last September, SharePoint Online is getting new branding capabilities that have been on the wish lists of...

Close