Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with Credit Card Validation
#3
Thanks Brandon,

Thanks for your response. While waiting, I tried the following code and it seems to work very well:

Code:
Dim checksum As Integer = 0
        Dim doubleflag As Boolean = (value.Length Mod 2 = 0)

        Dim digit As Char
        Dim digitvalue As Integer
        For Each digit In value
            digitvalue = Integer.Parse(digit)
            If doubleflag Then
                digitvalue *= 2
                If digitvalue > 9 Then
                    digitvalue -= 9
                End If
            End If
            checksum += digitvalue
            doubleflag = Not doubleflag
        Next
        Return (checksum Mod 10 = 0)
    End Function

I will give try adding the Return line as suggested, and see how well this works.
//Kismet


Messages In This Thread
Re: Help with Credit Card Validation - by kismetgerald - 08-25-2012, 05:02 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)