设3个参数wincount,tiecount,losecount
用户每选择一次,根据3个RadioButton的checked情况,分别将3个参数进行加1操作。最后将3个参数的值存入表中。

解决方案 »

  1.   

    我的大概想发是这样,当用户每点完一次,就按一个button,RadioButton变成空的,在让他点,在清空,最后在按另外一个button录入结果,
      

  2.   

    wincount=0;
    tiecount=0;
    losecount=0;
    radiobutton1onclick;
    wincount:=wincount+1;
    radiobutton2onclick;
    tiecount:=tiecount+1;
    ......form1onclose;
    sql:='insert into table(wincount,tiecount,losecount)';
    or sql:='update table set .....
      

  3.   

    是这样吗?
    procedure TForm1.RadioButton1Click(Sender: TObject);
    var
    wincount=0;
    begin
    wincount:=wincount+1;
    end;end.
      

  4.   

    假设你有一个Button1,用户每按一次,就提交上次的选择结果,并将3个RadioButton的选择状态都设为未选中。另有一个Button2,用户在做完所有的选择之后,按之,将结果提交到数据库。假设你用Table1连接数据库中的表。
    var
     wincnt,tiecnt,losecnt:integer;procedure TForm1.FormCreate(sender:TObject);
    begin
     wincnt:=0;
     tiecnt:=0;
     losecnt:=0;
    end; //在窗体创建时初始化参数procedure TForm1.Button1Click(sender:TObject); //记录结果
    begin
     if RadioButton1.checked then //win
      inc(wincnt);
     else if RadioButton2.checked then //tie
      inc(tiecnt);
     else if RadioButton3.checked then //lose
      inc(losecnt)
     else showMessage('请选择一个结果'); //什么都没选
    end;procedure TForm1.Button1Click(sender:TObject); //写数据库
    begin
     Table1.active:=true;
     Table1.insert;
     Table1.FieldByName('win').asInteger:=wincnt;
     Table1.FieldByName('tie').asInteger:=tiecnt;
     Table1.FieldByName('lose').asInteger:=losecnt;
     Table1.post;
    end;
      

  5.   

    谢谢,但是:
    if RadioButton1.checked then //win
      inc(wincnt);
     else if RadioButton2.checked then //tie
      inc(tiecnt);
     else if RadioButton3.checked then //lose
      inc(losecnt)
     else showMessage('请选择一个结果'); //什么都没选编译不对,我把else多去了,就对了,但现在我还有一个问题,就是如果我有三个GroupBox,那是不是要用3个表才可以呢?
      

  6.   

    抱歉,else前面不能有分号,将else前面的分号去掉就可以了。
    不一定啊,如果你的3个GruopBox的结果都只对应同样的3个字段,或者你的表里有9个字段,分别对应3个GroupBox中的3个结果;那一个表就够了。
      

  7.   

    我看了数据库里面是这样的:
    第一条记录:win:2,draw 1,lose 1。
    第2条记录:win:3,draw 2,lose 1。
    我如何才能显示第2条记录的结果呢?
      

  8.   

    分几种情形:
    1.如果你是要在表中进行统计的话,可以只设一个字段,用来记录每次点击的值,如下: 表Survey(SurveyID(IU), SurveyValue)
    每点一次,增加一条新记录,如下:
      Insert Survey(SurveyValue) values(点击值)
    用语句select SurveyValue, count(SurveyValue) as num 
          from Survey group by SurveyValue就可以统计出结果了
    2.如果只存一条记录,可以按你的方式建表,每次点击修改表中的数据即可.
      
    ================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★  浏览帖子速度极快![建议系统使用ie5.5以上]。 ★  多种帖子实现界面。 
    ★  保存帖子到本地[html格式]★  监视您关注帖子的回复更新。
    ★  可以直接发贴、回复帖子★  采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录! 
    ★  支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名  ●  
         可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
    Http://www.ChinaOK.net/csdn/csdn.rar
    Http://www.ChinaOK.net/csdn/csdn.exe    [自解压]
      

  9.   

    谢谢,指教,但我想问问如何实现,选择数据库中id值为最大的那条数据:
    select * from table1 where id=最大????????????????
      

  10.   

    select * from table1 where id=(select max(id) from table1)
      

  11.   

    但是那个query怎么不能及时更新呢?太奇怪了,是不是有什么设置?????????????????/
      

  12.   

    我用DBChart来显示统计的结果,不管怎么样,它只显示上一次的结果?我的DBChart是用query做为数据的,在query里面我写了select * from table1 where id=(select max(id) from table1)
      

  13.   

    query1.refresh;
    或者,强制更新
    query1.active:=false;
    query1.active:=true;
      

  14.   

    我是那样做的呀:
    procedure TForm2.FormCreate(Sender: TObject);
    begin
    with query1 do
    begin
        query1.active:=false;
        query1.active:=true;
        close;
        sql.clear;
        sql.add('select * from 表1 where id=(select max(id) from 表1)');    open;
    end;
    end;
    但还是显示上一次的记录,好奇怪呀