Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dv As String = Nothing Dim suma As Integer = 0 Dim iRut() As Char = StrReverse(TextBox1.Text.Trim) Dim j As Integer = 1 For i As Integer = 0 To iRut.Length - 1 j += 1 suma = suma + (Val(iRut(i)) * j) If j = 7 Then j = 1 End If Next dv = digitoVerificador(suma) If dv = TextBox2.Text.ToUpper Then MessageBox.Show("RUT CORRECTO!") Else MessageBox.Show("RUT INCORRECTO!") End If End Sub Public Function digitoVerificador(ByVal d_v As Integer) As String d_v = 11 - (d_v Mod 11) If d_v = 10 Then Return "K" ElseIf d_v = 11 Then Return "0" Else Return d_v End If End FunctionDescarga: http://bit.ly/1K0nTLs
lunes, 7 de septiembre de 2015
Validar Rut Chile
Suscribirse a:
Comentarios de la entrada (Atom)
No hay comentarios.:
Publicar un comentario