Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 19-02-2005
MiLLeNPuNk MiLLeNPuNk is offline
Registrado
 
Registrado: feb 2005
Posts: 4
Poder: 0
MiLLeNPuNk Va por buen camino
Error: " is not a valid integer value

Buenos dias, alguien me puede decir porque me sale un mensaje que dice: -" is not a valid integer value-, el error me lo da cuando tengo vacias unas casillas que me sirven para introducir un tiempo en un campo de tabla de tipo time, pero lo controlo y si estan vacios antes de introducirlo los pongo a 0, porque puede ser?, gracias, aqui os dejo el codigo del boton "agregar":

var
a:integer;
s:integer;
c:integer;
begin
s:=0;
c:=0;
almin.ReadOnly:=true;
alseg.ReadOnly:=true;
alalbums.Active:=true;
alalbums.First;
if (strtoint(alhora.text)>60) or (strtoint(almin.text)>60) or (strtoint(alseg.text)>60) then
begin
showmessage('Duraciòn incorrecta');
if strtoint(alhora.text)>60 then
begin
alhora.Text:='';
end;
if strtoint(almin.text)>60 then
begin
almin.text:='';
end;
if strtoint(alseg.text)>60 then
begin
alseg.text:='';
end;
s:=1;
end;
if alhora.Text='' then
begin
alhora.Text:='0';
end;
if almin.text='' then
begin
almin.text:='0';
end;
if alseg.text='' then
begin
alseg.Text:='0';
end;
for a:=alalbums.recordcount-1 downto 0 do
begin
if uppercase(alalbums.FieldByName('titulo').AsString)=uppercase(altitulo.text) then
begin
showmessage('El album ya existe');
s:=1;
end;
if (c=0) and ((alalanzamiento.text<'1900') or (alalanzamiento.text>'2005')) then
begin
showmessage('El año es incorrecto');
c:=1;
s:=1;
end;
alalbums.Next;
end;
if (altitulo.text='')
or (algrupo.text='')
or (alhora.text='') or (almin.text='') or (alseg.text='')
or (alalanzamiento.text='') then
begin
showmessage('Faltan datos por rellenar');
end;
if (s=0) and (altitulo.text<>'')
and (algrupo.text<>'')
and (alhora.text<>'') and (almin.text<>'') and (alseg.text<>'')
and (alalanzamiento.text<>'') then
begin
alalbums.last;
alalbums.Insert;
alalbums.FieldByName('titulo').AsString:=altitulo.Text;
alalbums.FieldByName('n_canciones').Asstring:=alncanciones.text;
alalbums.FieldByName('duracion').Asstring:=alhora.Text+':'+almin.text+':'+alseg.text;
alalbums.FieldByName('año_lanzamiento').Asstring:=alalanzamiento.text;
alalbums.FieldByName('grupo').AsString:=algrupo.Text;
showmessage('Album añadido');
altitulo.text:='';
algrupo.text:='';
alhora.text:='';
almin.Text:='';
alseg.text:='';
alalanzamiento.text:='';
alalbums.Post;
alalbums.Active:=false;
end;
s:=0;
a:=0;
b:=0;
c:=0;
d:=0;
Responder Con Cita
  #2  
Antiguo 19-02-2005
MasterXP MasterXP is offline
Miembro
 
Registrado: ene 2005
Posts: 193
Poder: 20
MasterXP Va por buen camino
Cita:
Empezado por MiLLeNPuNk
-" is not a valid integer value-, el error me lo da cuando tengo vacias unas casillas que me sirven para introducir un tiempo en un campo de tabla de tipo time,
Que Base de datos estas usando??
Responder Con Cita
  #3  
Antiguo 20-02-2005
Avatar de Lepe
[Lepe] Lepe is offline
Miembro Premium
 
Registrado: may 2003
Posts: 7.424
Poder: 28
Lepe Va por buen camino
Cuando en el Edit tienes un 3 y lo borras con la tecla retroceso, el edit queda en blanco, y justo en ese momento es cuando salta la excepción.

Solución: En el change del campo asociado, chequea el valor del campo, si es null entonces guardas el cero.

Otra opcion, no exclusiva, es usar TryStrtoInt, de esta forma, si el número no se puede convertir, ya tienes el valor por defecto sin que se lance la excepción.

Saludos

PD: StrToInt produce una excepción si el texto no se puede convertir.

Última edición por Lepe fecha: 20-02-2005 a las 11:58:44.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 22:25:32.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi