语法错误,“;”预期但 "ELSE" 找到 - IF-ELSE 条件错误 - FreePascal
Syntax error, ";" expected but "ELSE" found - Error with IF-ELSE condition - FreePascal
我不明白为什么我的代码不能编译,谁能帮我解决这个问题。
任何类型的评论都是有帮助的
这是代码:
procedure TForm1.Button2Click(Sender: TObject);
var
days : integer;
begin
if(Edit2.Text <> '') then
days:= StrToInt(Edit2.Text);
DDate.Minus(days);
Edit1.Text := DDate.GetDate
else
ShowMessage('The field is required');
end;
如果 true_statement 或 false_statement 需要两个或多个语句,则必须将语句组放在 begin ... end 块中
procedure TForm1.Button2Click(Sender: TObject);
var
days: integer;
begin
if(Edit2.Text <> '') then
begin
days := StrToInt(Edit2.Text);
DDate.Resta(days);
Edit1.Text := DDate.GetDate;
end
else
ShowMessage('The field is required');
end;
if后面的部分不应该放在begin-end块中吗?缩进表明如此。像这样:
procedure TForm1.Button2Click(Sender: TObject);
var
days : integer;
begin
if(Edit2.Text <> '') then
begin
days:= StrToInt(Edit2.Text);
DDate.Minus(days);
Edit1.Text := DDate.GetDate;
end
else
ShowMessage('The field is required');
end;
我不明白为什么我的代码不能编译,谁能帮我解决这个问题。 任何类型的评论都是有帮助的
这是代码:
procedure TForm1.Button2Click(Sender: TObject);
var
days : integer;
begin
if(Edit2.Text <> '') then
days:= StrToInt(Edit2.Text);
DDate.Minus(days);
Edit1.Text := DDate.GetDate
else
ShowMessage('The field is required');
end;
如果 true_statement 或 false_statement 需要两个或多个语句,则必须将语句组放在 begin ... end 块中
procedure TForm1.Button2Click(Sender: TObject);
var
days: integer;
begin
if(Edit2.Text <> '') then
begin
days := StrToInt(Edit2.Text);
DDate.Resta(days);
Edit1.Text := DDate.GetDate;
end
else
ShowMessage('The field is required');
end;
if后面的部分不应该放在begin-end块中吗?缩进表明如此。像这样:
procedure TForm1.Button2Click(Sender: TObject);
var
days : integer;
begin
if(Edit2.Text <> '') then
begin
days:= StrToInt(Edit2.Text);
DDate.Minus(days);
Edit1.Text := DDate.GetDate;
end
else
ShowMessage('The field is required');
end;