Verificador de rut chileno en visual basic

Páginas: 2 (378 palabras) Publicado: 7 de diciembre de 2010
VERIFICADOR DE RUT CHILENO EN VISUAL BASIC

Private Sub Form_Load()
Form1.Text1.MaxLength = 8
Form1.Text2.MaxLength = 1
Form1.Text1.FontSize = 18
Form1.Text2.FontSize = 18
Form1.Text1.TabStop= True
End Sub

Private Sub Command1_Click()
If (Text1 = "") And (Text2 = "") Then
MsgBox "No ha ingresado un R.U.T.", vbCritical, "Atención"
Text1 = ""
End If

'VALIDAR RUT
Dim i As IntegerDim X As Integer
Dim total As Integer
Dim totaltotal As Integer
Dim por As Integer
Dim rut As Integer
Dim guion As Integer
Dim nrut As Integer
Dim posicion As Integer
Dim valor As IntegerDim verdad As Boolean
Dim guionc As String

i = 1
total = 0
totaltotal = 0

rut = Len(Text1)
posicion = rut
por = 2

'RECORRER EL R.U.T.
For i = 1 To rut

If por = 8 Then
por = 2
End Iftotal = por * Val(Mid(Text1, posicion, 1))
posicion = posicion - 1
totaltotal = totaltotal + total
por = por + 1
Next

valor = totaltotal Mod 11
guion = Int(11 - valor)

If guion =Val(Mid(Text2, 1, 1)) Or guion = 10 And (Mid(Text2, 1, 1)) = "k" Or guion = 11 And (Mid(Text2, 1, 1)) = "0" Or guion = 10 And (Mid(Text2, 1, 1)) = "K" Then
verdad = True
If MsgBox("Rut valido ¿DeseaIngresar otro?", vbQuestion + vbYesNo, "Ingresar Otro") = vbYes Then
Text1 = ""
Text2 = ""

Else

End If

Else

If guion = 10 Then
guionc = "k"
MsgBox "Rut incorrecto, el digito verificador debe ser " & guionc, vbCritical, "Error....."
verdad = False
Text1 = ""
Text2 = ""

Text1 = ""
Text1.SetFocus

ElseMsgBox " Rut incorrecto, el digito verificador debe ser " & guion, vbCritical, "Error....."
verdad = False
Text1 = ""
Text2 = ""

Text1 = ""
Text1.SetFocus

End If

End IfEnd Sub
Private Sub text1_KeyPress(KeyAscii As Integer)
If (KeyAscii > 31 And KeyAscii < 48) Or KeyAscii > 57 Then
KeyAscii = 0
If KeyAscii 8 Then
If Not IsNumeric("0" &...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • digito verificador del rut
  • Visual basic
  • Que Es El Visual Basic
  • visual basic
  • Visual Basic
  • Que es visual basic
  • Visual basic
  • Que es visual basic

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS