Function to obtain check digit in VB6

In this opportunity we bring you a very useful function that will help us when we want to obtain the verifying digit of a Rut.

Function dv(rut as String)
 j = 2
 For i = 0 To Len(rut) - 1
   aux = aux + Val(Mid$(rut, Len(rut) - i, 1)) * j
   If j > 6 Then
    j = 2
   Else
    j = j + 1
   End If
 Next i
 aux1 = 11 - (aux Mod 11)
 If aux1 < 10 Then
   dv = aux1
 Else
   dv = "K"
 End If
End Function

We hope it is of your use.

regards

Deja una respuesta

Tu dirección de correo electrónico no será publicada.