Fórum URGENTE -END expected but ELSE found #469639
11/02/2014
0
Estou fazendo um programinha simples só pra eu começar a aprender.
Tenho 3 ''''Edit'''' que se estiverem preenchidos corretamente devem retornar num quarto edit a messagem ''''Banda x'''' e aparecer uma imagem.
Se não preenchidos corretamente deve aparecer a mensagem ''''Nao é a Banda X''''.
procedure TForm1.Button1Click(Sender: TObject);
begin
if (Edit1.Text = ''''Eder'''') and (Edit2.Text = ''''Carlos'''') and (Edit3.Text=''''Guilherme'''')
then Edit5.Text := ''''Banda x'''';
Image1.Visible := True
else Edit5.Text := ''''Não é Banda x''''
end;
end.
o erro que o sistema retorna é esse:
[Error] unMaior.pas(41): ''''END'''' expected but ''''ELSE'''' found
Por favor alguem pode me ajudar nisso
Eder Correa
Curtir tópico
+ 0Posts
11/02/2014
Luiz
if true then
begin
//mais de uma linha
//
end
else
begin
//mais de uma linha
//
end;
Quando for apenas 1 linha não é necessário utilizar o begin end (mas nao tem problema em utilizar)
if True then
ShowMessage('teste if ')
else ShowMessage('teste else');
Acredito que seu código ficaria assim:
procedure TForm1.Button1Click(Sender: TObject);
begin
if (Edit1.Text = 'Eder') and (Edit2.Text = 'Carlos') and (Edit3.Text='Guilherme') then
begin
Edit5.Text := 'Banda x';
Image1.Visible := True;
end
else
begin
Edit5.Text := 'Não é Banda x'
end;
end;
Gostei + 0
11/02/2014
Mr. White
procedure TForm1.Button1Click(Sender: TObject);
begin
if (Edit1.Text = ''''Eder'''') and (Edit2.Text = ''''Carlos'''') and (Edit3.Text=''''Guilherme'''') then
begin
Edit5.Text := ''''Banda x'''';
Image1.Visible := True
end
else Edit5.Text := ''''Não é Banda x''''
end;
end.Gostei + 0
11/02/2014
Eder Correa
if true then
begin
//mais de uma linha
//
end
else
begin
//mais de uma linha
//
end;
Quando for apenas 1 linha não é necessário utilizar o begin end (mas nao tem problema em utilizar)
if True then
ShowMessage('teste if ')
else ShowMessage('teste else');
Acredito que seu código ficaria assim:
procedure TForm1.Button1Click(Sender: TObject);
begin
if (Edit1.Text = 'Eder') and (Edit2.Text = 'Carlos') and (Edit3.Text='Guilherme') then
begin
Edit5.Text := 'Banda x';
Image1.Visible := True;
end
else
begin
Edit5.Text := 'Não é Banda x'
end;
end;
Perfeito Luiz. O Codigo rodou perfeitamente
Gostei + 0
11/02/2014
Luiz
Bons estudos amigo!
Abraços
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)