Funcion Verificador De RUT Para CHILE


Subject: Funcion Verificador De RUT Para CHILE
hola que tal
aquí dejo el codigo y el proyecto de un validador de rut para Chile... sirve mucho para aplicaciones de faturación, ingreso de personas.. nose... lo que se les ocurra...

bueno espero que sea de ayuda...
si lo mejoran sería genial... y ojala puedan compartir un update...

primero deben agregar la siguiente variable como cabezera en el codigo...
PRIVATE Pub_valida AS Boolean


aqui ta la funcion:
PRIVATE FUNCTION chequeRut(Rut_Valida AS String, Dig_Rut AS String)
DIM Tmp_Suma AS Integer
DIM Tmp_Largo AS Integer
DIM Tmp_Constante AS Integer
DIM Tmp_rut AS String
DIM Tmp_digito AS Integer
DIM Tmp_text_dig AS String
Tmp_text_dig = ""

Tmp_Constante = 1
Tmp_Largo = Len(Trim(Rut_Valida))
Tmp_rut = Val(Trim(Rut_Valida))
DO UNTIL Tmp_Largo = 0
Tmp_Constante = Tmp_Constante + 1
Tmp_Suma = Tmp_Suma + Mid(Tmp_rut, Tmp_Largo, 1) * Tmp_Constante
IF Tmp_Constante = 7 THEN
Tmp_Constante = 1
END IF
Tmp_Largo = Tmp_Largo - 1
LOOP
Tmp_digito = Tmp_Suma MOD 11
Tmp_text_dig = Str(11 - Tmp_digito)
IF Val(Tmp_text_dig) = 11 THEN
Tmp_text_dig = "0"
END IF
IF Val(Tmp_text_dig) = 10 THEN
Tmp_text_dig = "K"
END IF
IF Trim(Tmp_text_dig) <> Trim(Dig_Rut) THEN
Message.Error("El rut ingresado no es valido")
Pub_valida = FALSE
END IF
END


de esta forma llaman a la funcion con un button por ejemplo:
PUBLIC SUB Button1_Click()
Pub_valida = TRUE
chequeRut(Trim(TextBox1.Text), Trim(UCase(TextBox2.Text)))

IF Pub_valida = FALSE THEN
'instruccion en el caso que el rut ingresado sea invalido
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.SetFocus
ELSE
'instruccion en el caso que el rut sea valido
Message.Info("El rut ingresado es correcto!!! " & TextBox1.text & "-" & TextBox2.Text)
Button2.Visible = TRUE
END IF

END


bueno y por ultimo aqui dejo la descarga del formulario funcionando...

saludos espero sea de ayuda...


rut_chile.tar.gz
Description: funcion para verificar el rut de Chile... 
Download
Filename: rut_chile.tar.gz
Filesize: 9.55 KB
Downloaded: 134 Time(s)
rut_chile.tar.gz
Description: funcion para verificar el rut de Chile... 
Download
Filename: rut_chile.tar.gz
Filesize: 9.55 KB
Downloaded: 134 Time(s)
rut_chile.tar.gz
Description: funcion para verificar el rut de Chile... 
Download
Filename: rut_chile.tar.gz
Filesize: 9.55 KB
Downloaded: 134 Time(s)

Subject: Re: Funcion Verificador De RUT Para CHILE
Mas vale tarde que nunca, muchas gracias por el código de validación.

Profile PM  
Subject: Re: Funcion Verificador De RUT Para CHILE
Me habré caído de un guindo... pero ¿qué es un rut?
¿Es la fonética de root?

Profile PM  
Subject: Re: Funcion Verificador De RUT Para CHILE
Ja,ja, no Shordi. R.U.T es la abreviación de Rol Unico Tributario, y es un número que se utiliza para individualizar a una persona en Chile.
Es un carnet que sirve para realizar tramites bancarios, electrorales, etc.

Profile PM  
Subject: Re: Funcion Verificador De RUT Para CHILE
ok. Como el D.N.I (Documento Nacional de Identidad) en España, vamos... El Big Brother no descansa el pobre. Quiere siempre controlarnos a todos y, digo yo, con la vida aburrida que llevamos la mayoría... ¿No se aburrirá el pobre?
Gracias por la información, colega.

Profile PM  
Subject: Re: Funcion Verificador De RUT Para CHILE
Exacto.

Profile PM  
Subject: Re: Funcion Verificador De RUT Para CHILE
buena... ojala te sirva abarzuaf ....

saludos...


Page 1 of 1


  
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events

   

This is a "Lo-Fi" version of our main content. To view the full version with more information, formatting and images, please click here.

Powered by Icy Phoenix based on phpBB
Design by DiDiDaDo

Generation Time: 0.1049s (PHP: -10% SQL: 110%)
SQL queries: 25 - Debug Off - GZIP Enabled