Results 1 to 3 of 3

Thread: Credit Card Validation Function

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 1999
    Location
    Cary, NC, USA
    Posts
    17

    Post

    I got this Function of the VB-World Tips section. My question is about the 'IsEven' function it seems to be calling. VB6 throws an error, sub or function not defined. Is there a reference I have to have in the project for that function? Here is the code:
    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

    Any help would be appreciated. thank you.

  2. #2
    Fanatic Member
    Join Date
    Jan 1999
    Location
    UK
    Posts
    593

    Post

    Sorry, the IsEven function seems to have been omitted from the tip. Try this code:

    Function IsEven(lngNumber As Long) As Boolean

    If lngNumber Mod 2 = 0 Then
    IsEven = True
    Else
    IsEven = False
    End If

    End Function




    ------------------
    John Percival
    Editor, VB-World.net
    [email protected]



  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 1999
    Location
    Cary, NC, USA
    Posts
    17

    Post

    Thank you John.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width