VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Credit Card Checksum Checker

by John Anderson (2 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (106 Votes)

Checks to see if a Credit Card Number is valid by performing the LUHN-10 check on it.

Inputs
CCNum as String
Code Returns
True if Valid, False if Invalid
Side Effects
May cause skin irritation
API Declarations

Rate Credit Card Checksum Checker

Public Function IsValidCCNum(CCNum As String) As Boolean
  Dim i As Integer
  Dim total As Integer
  Dim TempMultiplier As String
  For i = Len(CCNum) To 2 Step -2
    total = total + CInt(Mid$(CCNum, i, 1))
    TempMultiplier = CStr((Mid$(CCNum, i - 1, 1)) * 2)
    total = total + CInt(Left$(TempMultiplier, 1))
    If Len(TempMultiplier) > 1 Then total = total + CInt(Right$(TempMultiplier, 1))
  Next
  If Len(CCNum) Mod 2 = 1 Then total = total + CInt(Left$(CCNum, 1))
  If total Mod 10 = 0 Then
    IsValidCCNum = True
  Else
    IsValidCCNum = False
  End If
End Function

Download this snippet    Add to My Saved Code

Credit Card Checksum Checker Comments

No comments have been posted about Credit Card Checksum Checker. Why not be the first to post a comment about Credit Card Checksum Checker.

Post your comment

Subject:
Message:
0/1000 characters