Aqui le adjunto la funcion que hace la validacion al RUC
Public Function ValidationRUC(ByVal ruc As String) As BooleanEjm:
Try
If Not IsNumeric(ruc) Then
Throw New Exception("El valor no es numerico")
End If
If ruc.Length <> 11 Then
Throw New Exception("Numero de digitos invalido")
End If
Dim dig01 As Integer = CInt(ruc.Substring(0, 1)) * 5
Dim dig02 As Integer = CInt(ruc.Substring(1, 1)) * 4
Dim dig03 As Integer = CInt(ruc.Substring(2, 1)) * 3
Dim dig04 As Integer = CInt(ruc.Substring(3, 1)) * 2
Dim dig05 As Integer = CInt(ruc.Substring(4, 1)) * 7
Dim dig06 As Integer = CInt(ruc.Substring(5, 1)) * 6
Dim dig07 As Integer = CInt(ruc.Substring(6, 1)) * 5
Dim dig08 As Integer = CInt(ruc.Substring(7, 1)) * 4
Dim dig09 As Integer = CInt(ruc.Substring(8, 1)) * 3
Dim dig10 As Integer = CInt(ruc.Substring(9, 1)) * 2
Dim dig11 As Integer = CInt(ruc.Substring(10, 1))
Dim suma As Integer = dig01 + dig02 + dig03 + dig04 + dig05 + dig06 + dig07 + dig08 + dig09 + dig10
Dim residuo As Integer = suma Mod 11
Dim resta As Integer = 11 - residuo
Dim digChk As Integer
If resta = 10 Then
digChk = 0
ElseIf resta = 11 Then
digChk = 1
Else
digChk = resta
End If
If dig11 = digChk Then
Return True
Else
Return False
End If
Catch ex As Exception
Throw ex
End Try
End Function
RUC = 10254824220
FACTOR = 5432765432
Se separa los 10 primeros digitos de la izquierda y se hace un calculo inividual
1 * 5 =5
0 * 4 = 0
2 * 3 = 6
5 * 2 = 10
4 * 7 = 28
8 * 6 = 48
2 * 5 = 10
4 * 4 = 16
2 * 3 = 6
2 * 2 = 4
Se suma el resultado de todas las multiplicaciones
SUMA = 133
Se calcula el residuo de la division por 11
133/ 11 = 1
RESIDUO = 1
Se resta 11 menos el residuo
11 - 1
RESTA = 10
digito de chequeo = RESTA
si resta = 10 entonces digito de cheque = 0
si resta = 11 entonces digito de cheque = 1
Por lo tanto el RUC 10254824220 es valido por que su digito numero 11 es 0 y el digito de chekeo es 0.