Advertisement
5_2007-2008 Custom Controls/ Forms/ Menus #173133

a Credit Card Number validation

Ever need to see if a credit card number is valid? Well, here is your chance. I did NOT write this code, I found it on the web!! Also, this may tell you if a number is valid, not if it works

AI

AIサマリー: 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.

ソースコード
original-source
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 (Len(CCNumber) Mod 2) Then
      TmpInt = Val(Mid$(CCNumber, Counter, 1))
      If Not (Counter Mod 2) Then
        TmpInt = TmpInt * 2
        If TmpInt > 9 Then TmpInt = TmpInt - 9
      End If
      Answer = Answer + TmpInt
      Counter = Counter + 1
    Else
      TmpInt = Val(Mid$(CCNumber, Counter, 1))
      If (Counter Mod 2) Then
        TmpInt = TmpInt * 2
        If TmpInt > 9 Then TmpInt = TmpInt - 9
      End If
      Answer = Answer + TmpInt
      Counter = Counter + 1
    End If
  Wend
  Answer = Answer Mod 10
  If Answer = 0 Then CheckCard = True
End Function

Upload
オリジナルのコメント (3)
Wayback Machineから復元