Calculo digito verificacion nit en userform y textbox
publicado
hola amigos , tengo el siguiente codigo para calcular el digito de verificacion del nit para colombia pero no se como usarlo para que me funcione utilizando dos textbox uno es donde se digita el nit y el otro donde arroja el resultado del DV :
Public Function DV(Nit)
Dim TipoRet, lnRetorno, Arreglo_PA(15), WSuma, WDato, WDig_Ver As Integer
TipoRet = VarType(Nit)
Select Case TipoRet
Case TipoRet = "C"
Nit = Trim(Nit)
Case TipoRet = "N" Or TipoRet = "Y"
Nit = Trim(Str(Nit))
End Select
Arreglo_PA(1) = 71
Arreglo_PA(2) = 67
Arreglo_PA(3) = 59
Arreglo_PA(4) = 53
Arreglo_PA(5) = 47
Arreglo_PA(6) = 43
Arreglo_PA(7) = 41
Arreglo_PA(8) = 37
Arreglo_PA(9) = 29
Arreglo_PA(10) = 23
Arreglo_PA(11) = 19
Arreglo_PA(12) = 17
Arreglo_PA(13) = 13
Arreglo_PA(14) = 7
Arreglo_PA(15) = 3
lnRetorno = 0
WDato = Right(Space(15) + Trim(Nit), 15)
WSuma = 0
WDig_Ver = 0
For i = 1 To 15
WSuma = WSuma + (Val(Mid(WDato, i, 1)) * Arreglo_PA(i))
Next i
WSuma = WSuma Mod 11
If WSuma = 0 Or WSuma = 1 Then
lnRetorno = WSuma
Else
lnRetorno = 11 - WSuma
End If
If TipoRet = "C" Then
DV = Trim(Str(lnRetorno))
Else
DV = lnRetorno
End If
End Function
espero su acostumbrada colaboracion..
Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
hola amigos , tengo el siguiente codigo para calcular el digito de verificacion del nit para colombia pero no se como usarlo para que me funcione utilizando dos textbox uno es donde se digita el nit y el otro donde arroja el resultado del DV :
Public Function DV(Nit)
Dim TipoRet, lnRetorno, Arreglo_PA(15), WSuma, WDato, WDig_Ver As Integer
TipoRet = VarType(Nit)
Select Case TipoRet
Case TipoRet = "C"
Nit = Trim(Nit)
Case TipoRet = "N" Or TipoRet = "Y"
Nit = Trim(Str(Nit))
End Select
Arreglo_PA(1) = 71
Arreglo_PA(2) = 67
Arreglo_PA(3) = 59
Arreglo_PA(4) = 53
Arreglo_PA(5) = 47
Arreglo_PA(6) = 43
Arreglo_PA(7) = 41
Arreglo_PA(8) = 37
Arreglo_PA(9) = 29
Arreglo_PA(10) = 23
Arreglo_PA(11) = 19
Arreglo_PA(12) = 17
Arreglo_PA(13) = 13
Arreglo_PA(14) = 7
Arreglo_PA(15) = 3
lnRetorno = 0
WDato = Right(Space(15) + Trim(Nit), 15)
WSuma = 0
WDig_Ver = 0
For i = 1 To 15
WSuma = WSuma + (Val(Mid(WDato, i, 1)) * Arreglo_PA(i))
Next i
WSuma = WSuma Mod 11
If WSuma = 0 Or WSuma = 1 Then
lnRetorno = WSuma
Else
lnRetorno = 11 - WSuma
End If
If TipoRet = "C" Then
DV = Trim(Str(lnRetorno))
Else
DV = lnRetorno
End If
End Function
espero su acostumbrada colaboracion..