elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  validar rut....
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: validar rut....  (Leído 4,057 veces)
NEMESIS_69

Desconectado Desconectado

Mensajes: 2


Ver Perfil
validar rut....
« en: 13 Diciembre 2006, 16:48 pm »

aca les va un codigo chiko de validacion de rut; pa los que cachan no mas como implementarlos...
Ojala me puedan ayudar a mejorarlo ya que lo que quiero lograr es anotar el rut de cualquier forma y al validarlo me lo muestre en un texbox nuevo con caracteres en el formato de salid xx.xxx.xxx-x a ver que sale ....

ACA EL CODIGO:

Código:
Public Class Form1 


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'MENSAJE CUANDO NO SE ESCRIBE RUT

If (TextBox1.Text = "") And (TextBox2.Text = "") Then
MsgBox("No ha ingresado un R.U.T.", vbCritical, "Atención")
TextBox1.Text = ""
End If

'VALIDAR RUT
Dim i As Integer
Dim 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 Integer
Dim verdad As Boolean

i = 1
total = 0
totaltotal = 0

rut = Len(TextBox1.Text)
posicion = rut
por = 2


If Val(TextBox1.Text) = 15662171 And Val(TextBox2.Text) = 4 Then
MsgBox("ESTE ES EL RUT DEL JAVIER PIZARRO", vbCritical, "ATENCION")
End If

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

If por = 8 Then
por = 2
End If

total = por * Val(Mid(TextBox1.Text, posicion, 1))
posicion = posicion - 1
totaltotal = totaltotal + total
por = por + 1
Next

valor = totaltotal Mod 11
guion = Int(11 - valor)
If guion = Val(Mid(TextBox2.Text, 1, 1)) Or guion = 10 And (Mid(TextBox2.Text, 1, 1)) = "k" Or guion = 11 And (Mid(TextBox2.Text, 1, 1)) = "0" Or guion = 10 And (Mid(TextBox2.Text, 1, 1)) = "K" Then
verdad = True
If MsgBox("Rut valido ¿Desea Ingresar otro?", vbQuestion + vbYesNo, "Ingresar Otro") = vbYes Then
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
Else
End
End If
Else
MsgBox(" El R.U.T. ingresado NO es Valido", vbCritical, "Error.....")
verdad = False
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If
End Sub

Private Sub Button1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove
Label3.Text = "Click aquí para validar el R.U.T."
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End Sub
Private Sub Label2_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label2.MouseMove
Label3.Text = ""
End Sub
Private Sub TextBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseMove
Label1.Text = "Ingrese aquí su R.U.T."
If Len(TextBox1.Text) > 0 And Len(TextBox1.Text) < 6 Then
MsgBox(" Ingrese minimo 6 digitos", vbCritical, "Error.....")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If
End Sub

Private Sub Form1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
Label3.Text = ""
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End
End Sub

Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim keyAscii As Integer
Dim largo As Integer
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 13 Then
KeyAscii = 0
End If

If KeyAscii = 13 Then
TextBox2.Focus()
largo = Len(TextBox1.Text)
If largo < 7 Then
MsgBox("Ingrese minimo 7", vbCritical, "Alerta")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If
End If
largo = Len(TextBox1.Text)
If largo > 9 Then
MsgBox("Ingrese maximos 9 digitos", vbCritical, "Alerta")
End If
End Sub

Private Sub TextBox2_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
Dim corto As Integer
Dim KeyAscii As Integer
If (KeyAscii < 48) Or (KeyAscii > 57) And (KeyAscii <> 75) And (KeyAscii <> 107) Then
KeyAscii = 0
End If
corto = Len(TextBox2.Text)
If corto > 1 Then
MsgBox("ingrese solo un caracter (0,1 ,2 , 3, 4, 5, 6, 7, 8, 9, k)", vbCritical, "Alerta")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If
End Sub
End Class


« Última modificación: 13 Diciembre 2006, 16:57 pm por NEMESIS_69 » En línea

sp26

Desconectado Desconectado

Mensajes: 88


Ver Perfil
Re: validar rut....
« Respuesta #1 en: 13 Diciembre 2006, 22:37 pm »

No entiendo... si pudieras especificar mas seria mejor...


En línea

NEMESIS_69

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Re: validar rut....
« Respuesta #2 en: 14 Diciembre 2006, 16:46 pm »

No entiendo... si pudieras especificar mas seria mejor...

Quiero modificar su estructura de tal forma de que el rut uede almacenado en un arrego en donde yo pueda manejar el ingreso de datos; sin importar lo que ponga el usuario..

Osea que en el tex1 si van a poner 15662171-4 o 156621714; algun otro label o tex2 lo muestre como 15.662.171-4 a parte de validarlo automaticamente cuando termine el procedimiento onkeypress...
gracias
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Validar envio de FTP
Windows
bricenoch 4 2,877 Último mensaje 26 Octubre 2011, 18:33 pm
por morenochico
validar horas php
PHP
kakashi20 3 4,129 Último mensaje 29 Diciembre 2011, 19:46 pm
por kakashi20
Validar MaxLenght
PHP
ganondolf 1 1,377 Último mensaje 25 Abril 2012, 06:35 am
por Shell Root
Duda sobre validar int
Programación Visual Basic
esternocleidomastoideo 1 1,603 Último mensaje 13 Octubre 2022, 14:26 pm
por Elektro Enjuto
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines