Public Shared Function ValidateCCNumber(ByVal sCCNumber As String) As Boolean Dim i, w, y As Integer Dim x As String y = 0 sCCNumber = sCCNumber.Trim() w = 2 * (Len(sCCNumber) Mod 2) For i = Len(sCCNumber) - 1 To 1 Step -1 x = Mid(sCCNumber, i, 1) If IsNumeric(x) Then Select Case (i Mod 2) + w Case 0, 3 y = y + CInt(x) Case 1, 2 x = CInt(x) * 2 If x > 9 Then y = y + (x \ 10) + (x - 10) Else y = y + x End If End Select End If Next y = 10 - (y Mod 10) If y > 9 Then y = 0 Return (CStr(y) = Right(sCCNumber, 1)) End Function
Remember Me
Powered by: newtelligence dasBlog 1.8.5223.2
© Copyright 2008, Troy DeMonbreun
E-mail