Fórum EconvertError #592659
22/04/2018
0
FALA GALERA ESTOU COM UM TRABALHO DA FACULDADE EM DELPHI PRA FAZER UM CADASTRO DE PACIENTE E CALCULO DE IMC SO QUE O NOME, ALTURA, PESO ELE LER NO MEMO1 MAS O SEXO NAO LER E DAR SEMPRE UM ERRO DE Project tcc.exe raised exception class EConvertError with message '''''' is not a valid integer value''. NAO SEI AONDE EU TO ERRANDO E NAO CONSIGO CHAMAR. O SEXO APARECE NO ARQUIVO TXT MAS NAO MOSTRA NA TELA DO MEMO1. ALGUEM PODE ME AJUDAR???
Jose Filho
Curtir tópico
+ 0
Responder
Posts
23/04/2018
Natanael Ferreira
EConvertError with message '''''' is not a valid integer value''
Erro de conversão de um valor vazio para inteiro. Verifique se não está tentando converter uma string vazia.
Se não conseguir, poste como está seu código para analisarmos.
Responder
Gostei + 0
23/04/2018
Jose Filho
Essa parte ja resolvi mas aparece um erro na tela assim '| Masculino' is not a valid floating point value. quando eu coloco meu programa pra ler.
segue o codigo
var
Cadastro_e_IMC_frm: TCadastro_e_IMC_frm;
var arq: TextFile;
implementation
{$R *.dfm}
procedure TCadastro_e_IMC_frm.BitBtn1Click(Sender: TObject);
begin
if ((edNome.Text <> '') and (edsexo.Text <> '') and
(edalt.Text <> '') and (edpes.Text <> ''))
then begin
Writeln(arq, edNome.Text, ' | ', edsexo.Text, ' | ',
edalt.Text, ' | ', edpes.Text, ' | ');
edNome.Clear;
edsexo.Clear;
edalt.Clear;
edpes.Clear;
end;
end;
procedure TCadastro_e_IMC_frm.BitBtn2Click(Sender: TObject);
var
linha, nome: string;
nreg, i: integer;
alt, pes, imc: real;
sexo: extended;
begin
Memo1.Clear;
Reset(arq);
nreg := 0;
while (not Eof(arq)) do
begin
Readln(arq, linha);
nreg := nreg + 1;
i := pos(' | ', linha);
Nome := copy(linha, 1, i-1);
delete(linha, 1, i);
i := pos(' | ', linha);
Sexo := StrToFloat(copy(linha, 1, i-1));
i := pos(' | ', linha);
Alt := StrToFloat(copy(linha, 1, i-1));
delete(linha, 1, i);
i := pos(' | ', linha);
Pes := StrToFloat(copy(linha, 1, i-1));
i := pos(' | ', linha);
IMC := StrToFloat(copy(linha, 1, i-1));
delete(linha, 1, i);
alt := sqr(alt);
IMC := pes/alt;
Memo1.Lines.Add('Registro Nro.: ' + IntToStr(nreg));
Memo1.Lines.Add('Nome..........: ' + nome);
Memo1.Lines.Add('Sexo..........: ' + FloatTostr(Sexo));
Memo1.Lines.Add('Altura(m).....: ' + FloatToStr(Alt));
Memo1.Lines.Add('Peso(kg)......: ' + FloatToStr(Pes));
Memo1.Lines.Add('IMC...........: ' + FloatToStr(IMC));
if (IMC < 16)
then Memo1.Lines.Add('Situação......: Magreza grave')
else if ((IMC >= 16) and (IMC < 17))
then Memo1.Lines.Add('Situação......: Magreza moderada')
else if ((IMC >= 17) and (IMC < 18.5))
then Memo1.Lines.Add('Situação......: Magreza leve')
else if ((IMC >= 18.5) and (IMC < 25))
then Memo1.Lines.Add('Situação......: Saudável')
else if ((IMC >= 25) and (IMC < 30))
then Memo1.Lines.Add('Situação......: Sobrepeso')
else if ((IMC >= 30) and (IMC < 35))
then Memo1.Lines.Add('Situação......: Obesidade Grau I')
else if ((IMC >= 35) and (IMC < 40))
then Memo1.Lines.Add('Situação......: Obesidade Grau II (severa)')
else if (IMC > 40)
then Memo1.Lines.Add('Situação......: Obesidade Grau III (mórbida)');
end;
CloseFile(arq);
Append(arq);
end;
procedure TCadastro_e_IMC_frm.BitBtn3Click(Sender: TObject);
begin
close;
end;
procedure TCadastro_e_IMC_frm.edaltKeyPress(Sender: TObject; var Key: Char);
begin
if (Key in ['.', ','])
then if (pos(',', (Sender as TEdit).Text) = 0)
then Key := ','
else Key := #7
else if not(Key in ['0'..'9',#8]) then Key := #0;
end;
procedure TCadastro_e_IMC_frm.edpesKeyPress(Sender: TObject; var Key: Char);
begin
if (Key in[])
then if (pos(',', (Sender as TEdit).Text) = 7)
then Key := ','
else Key := #7
else if not(Key in ['0'..'9',#8]) then Key := #7;
end;
procedure TCadastro_e_IMC_frm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
CloseFile(arq);
end;
procedure TCadastro_e_IMC_frm.FormShow(Sender: TObject);
begin
AssignFile(arq, 'C:\\Users\\Claudinho\\Desktop\\Cadastro de Parciente e IMC\\Cadastro_de_Paciente_e_Calculo_do_IMC.txt');
Reset(arq);
if (IOResult <> 0)
then Rewrite(arq)
else begin
CloseFile(arq);
Append(arq);
end;
end;
end.
ja estou doido pq o nome, altura, peso, imc e a situação do imc aparece no memo mas o sexo nao
segue o codigo
var
Cadastro_e_IMC_frm: TCadastro_e_IMC_frm;
var arq: TextFile;
implementation
{$R *.dfm}
procedure TCadastro_e_IMC_frm.BitBtn1Click(Sender: TObject);
begin
if ((edNome.Text <> '') and (edsexo.Text <> '') and
(edalt.Text <> '') and (edpes.Text <> ''))
then begin
Writeln(arq, edNome.Text, ' | ', edsexo.Text, ' | ',
edalt.Text, ' | ', edpes.Text, ' | ');
edNome.Clear;
edsexo.Clear;
edalt.Clear;
edpes.Clear;
end;
end;
procedure TCadastro_e_IMC_frm.BitBtn2Click(Sender: TObject);
var
linha, nome: string;
nreg, i: integer;
alt, pes, imc: real;
sexo: extended;
begin
Memo1.Clear;
Reset(arq);
nreg := 0;
while (not Eof(arq)) do
begin
Readln(arq, linha);
nreg := nreg + 1;
i := pos(' | ', linha);
Nome := copy(linha, 1, i-1);
delete(linha, 1, i);
i := pos(' | ', linha);
Sexo := StrToFloat(copy(linha, 1, i-1));
i := pos(' | ', linha);
Alt := StrToFloat(copy(linha, 1, i-1));
delete(linha, 1, i);
i := pos(' | ', linha);
Pes := StrToFloat(copy(linha, 1, i-1));
i := pos(' | ', linha);
IMC := StrToFloat(copy(linha, 1, i-1));
delete(linha, 1, i);
alt := sqr(alt);
IMC := pes/alt;
Memo1.Lines.Add('Registro Nro.: ' + IntToStr(nreg));
Memo1.Lines.Add('Nome..........: ' + nome);
Memo1.Lines.Add('Sexo..........: ' + FloatTostr(Sexo));
Memo1.Lines.Add('Altura(m).....: ' + FloatToStr(Alt));
Memo1.Lines.Add('Peso(kg)......: ' + FloatToStr(Pes));
Memo1.Lines.Add('IMC...........: ' + FloatToStr(IMC));
if (IMC < 16)
then Memo1.Lines.Add('Situação......: Magreza grave')
else if ((IMC >= 16) and (IMC < 17))
then Memo1.Lines.Add('Situação......: Magreza moderada')
else if ((IMC >= 17) and (IMC < 18.5))
then Memo1.Lines.Add('Situação......: Magreza leve')
else if ((IMC >= 18.5) and (IMC < 25))
then Memo1.Lines.Add('Situação......: Saudável')
else if ((IMC >= 25) and (IMC < 30))
then Memo1.Lines.Add('Situação......: Sobrepeso')
else if ((IMC >= 30) and (IMC < 35))
then Memo1.Lines.Add('Situação......: Obesidade Grau I')
else if ((IMC >= 35) and (IMC < 40))
then Memo1.Lines.Add('Situação......: Obesidade Grau II (severa)')
else if (IMC > 40)
then Memo1.Lines.Add('Situação......: Obesidade Grau III (mórbida)');
end;
CloseFile(arq);
Append(arq);
end;
procedure TCadastro_e_IMC_frm.BitBtn3Click(Sender: TObject);
begin
close;
end;
procedure TCadastro_e_IMC_frm.edaltKeyPress(Sender: TObject; var Key: Char);
begin
if (Key in ['.', ','])
then if (pos(',', (Sender as TEdit).Text) = 0)
then Key := ','
else Key := #7
else if not(Key in ['0'..'9',#8]) then Key := #0;
end;
procedure TCadastro_e_IMC_frm.edpesKeyPress(Sender: TObject; var Key: Char);
begin
if (Key in[])
then if (pos(',', (Sender as TEdit).Text) = 7)
then Key := ','
else Key := #7
else if not(Key in ['0'..'9',#8]) then Key := #7;
end;
procedure TCadastro_e_IMC_frm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
CloseFile(arq);
end;
procedure TCadastro_e_IMC_frm.FormShow(Sender: TObject);
begin
AssignFile(arq, 'C:\\Users\\Claudinho\\Desktop\\Cadastro de Parciente e IMC\\Cadastro_de_Paciente_e_Calculo_do_IMC.txt');
Reset(arq);
if (IOResult <> 0)
then Rewrite(arq)
else begin
CloseFile(arq);
Append(arq);
end;
end;
end.
ja estou doido pq o nome, altura, peso, imc e a situação do imc aparece no memo mas o sexo nao
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)