Advertisement
2002VB Miscellaneous #17348

Credit Card Checksum Checker

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

AI

Resumo por IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Código fonte
original-source
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
Comentários originais (3)
Recuperado do Wayback Machine