Talvez isso ajude procedure TForm1.Button1Click(Sender: TObject); var EN, EX, EI: integer; ER, Res: integer; begin // Aqui eu pego o valor de ER ER := StrToInt(Edit1.Text); // Aqui eu inicializo as variáveis para nao dar warnnings Res := 0; EX:=1; EI:=1; // Aqui verificamos entre quais valores está o ER if (ER in [0..7]) then Res := 0; if (ER in [8..12]) then Res := 1; if (ER in [13..20]) then Res := 2; if (ER in [21..27]) then Res := 3; if (ER in [28..35]) then Res := 4; if (ER in [36..43]) then Res := 5; if (ER in [44..50]) then Res := 6; if (ER in [51..58]) then Res := 7; if (ER in [59..66]) then Res := 8; if (ER in [67..74]) then Res := 9; if (ER in [75..81]) then Res := 10; if (ER in [82..89]) then Res := 11; if (ER in [90..97]) then Res := 12; if (ER in [98..104]) then Res := 13; if (ER > 104) then Res := 14; // Fazemos a soma EN:= EX + EI + Res; // Exibimos o resultado ShowMessage('O valor é: '+IntToStr(EN)); end;
Pessoal é o seguinte, tenho um DBEdit1 onde eu digito a data, quero que logo após eu digitar a data, em outros 4 DBEdits seja jogado um valor que eu calculo dentro do evento deste DBEdit1, porém... eu não sei em que evento do DBEdti1 eu tenho que implementar os calculos.. alguém me ajuda? Deixo aqui o codigo que estou tentando utilizar para um dos calculos, o qual retorna erro dizendo que "Variable 'Res' might not have been initialized". Ao clicar no botão o resultado que é mostrado é 3, mas o certo deveria ser 7, visto que o numero de registros atuais da minha tabela Distrito é 35. procedure TFormUnidade.BitBtn7Click(Sender: TObject); var EN, EX, EI: integer; ER, Res: integer; begin ER := DataModule1.DistDataSource.DataSet.RecordCount; if (ER > 0) and (ER < 7) then begin Res:= 0; end; if (ER > 6) and (ER < 12) then begin Res:= 1; end; if (ER > 11) and (ER < 20) then begin Res:= 2; end; if (ER > 19) and (ER < 27) then begin Res:= 3; end; if (ER > 26) and (ER < 35) then begin Res:= 4; end; if (ER > 34) and (ER < 43) then begin Res:= 5; end; if (ER > 42) and (ER < 50) then begin Res:= 6; end; if (ER > 49) and (ER < 58) then begin Res:= 7; end; if (ER > 57) and (ER < 66) then begin Res:= 8; end; if (ER > 65) and (ER < 74) then begin Res:= 9; end; if (ER > 73) and (ER < 81) then begin Res:= 10; end; if (ER > 80) and (ER < 89) then begin Res:= 11; end; if (ER > 88) and (ER < 97) then begin Res:= 12; end; if (ER > 96) and (ER < 104) then begin Res:= 13; end; if (ER > 103) then begin Res:= 14; end; EX:=1; EI:=1; EN:= EX + EI + Res; DBEdit11.text := InttoStr(EN); end; --------------------------------- Yahoo! Acesso Grátis: Internet rápida e grátis. Instale o discador agora! [As partes desta mensagem que não continham texto foram removidas] -- <<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>> Para ver as mensagens antigas, acesse: http://br.groups.yahoo.com/group/delphi-br/messages Para falar com o moderador, envie um e-mail para: [EMAIL PROTECTED] ou [EMAIL PROTECTED] Yahoo! Grupos, um serviço oferecido por: São Paulo Rio de Janeiro Curitiba Porto Alegre Belo Horizonte Brasília Links do Yahoo! Grupos Para visitar o site do seu grupo na web, acesse: http://br.groups.yahoo.com/group/delphi-br/ Para sair deste grupo, envie um e-mail para: [EMAIL PROTECTED] O uso que você faz do Yahoo! Grupos está sujeito aos Termos do Serviço do Yahoo!. ---------- [As partes desta mensagem que não continham texto foram removidas] -- <<<<< FAVOR REMOVER ESTA PARTE AO RESPONDER ESTA MENSAGEM >>>>> Para ver as mensagens antigas, acesse: http://br.groups.yahoo.com/group/delphi-br/messages Para falar com o moderador, envie um e-mail para: [EMAIL PROTECTED] ou [EMAIL PROTECTED] Links do Yahoo! Grupos <*> Para visitar o site do seu grupo na web, acesse: http://br.groups.yahoo.com/group/delphi-br/ <*> Para sair deste grupo, envie um e-mail para: [EMAIL PROTECTED] <*> O uso que você faz do Yahoo! Grupos está sujeito aos: http://br.yahoo.com/info/utos.html