![]() |
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; |
Cita:
|
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. |
La franja horaria es GMT +2. Ahora son las 15:25:54. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi