|
|
|
|
|
Dicas
|
|
Visual Basic.Net (Validações)
|
|
|
Título da Dica: Validador de cartões de crédito em VB.Net
|
|
|
|
Postada em 9/2/2004 por PC
Public Function IsValid(ByVal strNumber As String) As Boolean Dim lngResult As Integer Dim lngTotal As Integer Dim intIndex As Short Dim i As Short Dim x As Short x = 1 For i = Len(strNumber) To 1 Step -1 lngResult = (CShort(Mid(strNumber, i, 1)) * x) If lngResult >= 10 Then lngTotal = lngTotal + (CShort(Mid(CStr(lngResult), 1, 1)) + CShort(Mid(CStr(lngResult), 2, 1))) Else lngTotal = lngTotal + lngResult End If If x = 2 Then x = 1 Else x = 2 Next If lngTotal Mod 10 = 0 Then IsValid = True Else IsValid = False End If End Function
|
|
|
|
|