PDA

Ver la Versión Completa : Validar cuenta bancaria


paladincubano
04-12-2008, 17:55:23
Hola foreros,
Alguno sabe el algoritmo de como validar una cuenta bancaria entrada por el usuario??
Gracias.

marcoszorrilla
04-12-2008, 18:00:05
Mira esta función:



//****** COMPRUEBA LOS DIGITOS DE CONTROL DEL CCC ******************************
function ControlDigitosCCC(CCC:string):boolean;
const
Pesos:array [0..9] of byte =(1,2,4,8,5,10,9,7,3,6);
var
DC1,DC2,c,Resto:integer;
st1,st2:string;
begin
Result:=False;
st1:=Copy(CCC,1,8);
st2:=Copy(CCC,11,10);
DC1:=0;
DC2:=0;

for c:=0 to length(st1)-1 do
begin
try
Dc1:=Dc1+strtoint(copy(st1,c+1,1))*Pesos[c+2];
except
exit;
end;
end;

Resto:=DC1 mod 11;
Dc1:=11-Resto;
if DC1=10 then DC1:=1;
if DC1=11 then DC1:=0;

for c:=0 to length(st2)-1 do
begin
try
Dc2:=Dc2+strtoint(copy(st2,c+1,1))*Pesos[c];
except
exit;
end;
end;

Resto:=DC2 mod 11;
Dc2:=11-Resto;
if DC2=10 then DC2:=1;
if DC2=11 then DC2:=0;

try
if (DC1=strtoint(Copy(CCC,9,1))) and (DC2=strtoint(Copy(CCC,10,1))) then Result:=True;
except
end;
end;

Comprobaciones en esta dirección (http://www.maestre-ediban.com/digito_control2.htm):

Un Saludo.

paladincubano
04-12-2008, 18:03:59
Estupendo!!!!!!
Gracias