<%
'-----------------------------------------------------
'Funcao: IsPISPASEP(BYVal strPISPASEP)
'Sinopse: Verifica se o valor passado é um PISPASEP
' válido
'Parametro: strPISPASEP
'Retorno: Booleano
'Autor: Gabriel Fróes - www.codigofonte.com.br
'-----------------------------------------------------
Function IsPISPASEP(BYVal strPISPASEP)
Dim strPeso
Dim intTotal
Dim intCont
Dim intResultado
intTotal = 0
strPeso = "3298765432"
'Validando a entrada dos dados
If strPISPASEP = "" Or Len(strPISPASEP) <> 11 Then
IsPISPASEP = False
Exit Function
End If
For intCont = 1 To 10
intResultado = Mid(strPISPASEP, intCont, 1) * Mid(strPeso,intCont, 1)
intTotal = intTotal + intResultado
Next
'Resto da Divisao
intResto = intTotal Mod 11
If intResto <> 0 Then
intResto = 11 - intResto
End If
If intResto = 10 Or intResto = 11 Then
intResto = Mid(intResto, 2, 1)
End If
If Cint(intResto) <> Cint(Mid(strPISPASEP, 11, 1)) Then
IsPISPASEP = False
Exit Function
End If
IsPISPASEP = True
End Function
%>
Testando o código:<br>
<% If IsPISPASEP("12660277515") Then %>
<font color='green'>O PISPASEP está Correto!</font>
<% Else %>
<font color='red'>O PISPASEP está Incorreto!</font>
<% End If %>