春雨田 发表于 2019-3-28 09:09:51

小白遇到的问题,请高手帮忙

本帖最后由 春雨田 于 2019-3-28 09:11 编辑

这是按教程输入的代码,实际执行中遇到了几个问题,但与教程代码核对了几遍没有发现输错代码,请教高手到底差在哪了?谢谢!!
procedure TForm1.RadioButton1Click(Sender: TObject); //选择性别
begin
if radiobutton1.checked then
    str_sex:='男';
elseif radiobutton2.checkedthen
    str_sex:='女';
end;

凌九霄 发表于 2019-3-28 11:14:45

注意begin...end的使用
procedure TForm1.Button1Click(Sender: TObject);
begin

if radiobutton1.checked then
begin
    str_sex:='男';
end
elseif radiobutton2.checkedthen
begin
       str_sex:='女';
end;
end;
end.

春雨田 发表于 2019-3-28 14:26:54

谢谢楼上指点。但我运行后还是报错见图:TForm1.RadioButton1Click(Sender: TObject); //选择性别
begin
if radiobutton1.checked then
    str_sex:='男';
end
    else if radiobutton2.checked then
    begin
      str_sex:='女';
    end;
end;
end.
出错信息如下:
构建
[错误] Unit1.pas(51): ';' expected but 'ELSE' found
[错误] Unit1.pas(55): '.' expected but 'END' found
[错误] Unit1.pas(29): Unsatisfied forward or external declaration: 'TForm1.RadioGroup1Click'
[错误] Unit1.pas(30): Unsatisfied forward or external declaration: 'TForm1.CheckBox1Click'
[错误] Unit1.pas(31): Unsatisfied forward or external declaration: 'TForm1.Button1Click'
[致命错误] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

凌九霄 发表于 2019-3-28 17:35:57

本帖最后由 凌九霄 于 2019-3-28 17:37 编辑

春雨田 发表于 2019-3-28 14:26
谢谢楼上指点。但我运行后还是报错见图:
出错信息如下:
构建


明显你又写漏了if 下面的 begin

春雨田 发表于 2019-3-29 09:35:12

谢谢!!问题已经解决。以后还得认真点。

zxpgggh 发表于 2019-3-29 14:21:58

学习了

cplus 发表于 2019-8-7 14:30:11

楼主,问题解决了,请结帖!
页: [1]
查看完整版本: 小白遇到的问题,请高手帮忙