Created
July 9, 2019 17:19
-
-
Save snake575/2a46fd48eb26658e5d7cf7ade3e18cf4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function RUTDV(rut) | |
rut = Replace("0000" & rut, ".", "", 1) | |
If InStr(1, rut, "-") > 0 Then rut = Left(rut, InStr(1, rut, "-") - 1) | |
rut = Right(rut, 8) | |
suma = 0 | |
For i = 1 To 8 | |
suma = suma + Val(Mid(rut, i, 1)) * Val(Mid("32765432", i, 1)) | |
Next i | |
dv = 11 - (suma Mod 11) | |
If dv = 10 Then dv = "k" | |
If dv = 11 Then dv = 0 | |
dvrut = dv | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment