不用for
就用do while自已step多少都行

解决方案 »

  1.   

    用while...do循环取代。没有类似VB中的STEP语句。
    另PASCAL没有DO WHILE,只有REPEAT...UNTIL
      

  2.   

    用mod
    var
       i:integer;
    begin
       for i:=1 to 17  do
        if i mod 3=0 then
         showmessage(inttostr(i));
    end;
      

  3.   

    谢谢啦
    用while do 也一样吧
    请帮我看一下以下代码,它会对条记录执行两次insert,也就是两条记录一样
    for ii:=1 to setCenterFrm.StringGrid1.RowCount-1 do
    begin
     sqlStr:='"'+setCenterFrm.StringGrid1.Cells[0,ii]+'"';
     for i:=1 to 3 do//StringGrid1.ColCount-1
     begin
     sqlStr:=sqlStr+',"'+setCenterFrm.StringGrid1.Cells[i,ii]+'"';
     end;
     prograssFrm.Label2.caption:=setCenterFrm.StringGrid1.Cells[1,ii]+'→'+setCenterFrm.StringGrid1.Cells[2,ii]+'→'+setCenterFrm.StringGrid1.Cells[3,ii]+'→'+setCenterFrm.StringGrid1.Cells[4,ii];
     prograssFrm.label2.Update;
     prograssFrm.label3.Caption:=inttostr(ii);
     prograssFrm.label3.Update;
     sqlstr:='insert into sale (room,block,house,floor) values ('+sqlStr+')';//,area_room,area_terrace,area_other,unitPrice_room,unitPrice_terrace,unitPrice_other,total_area,total_fund,image1,image2,image3,direction,house_type
     if setCenterFrm.stringGrid1.Cells[0,ii]<>sqlStrOld then mainFrm.Query(sqlstr);
     sqlStrOld:=setCenterFrm.stringGrid1.Cells[0,ii];
    end;
    procedure Tmainfrm.query(sqlStr:string);
    begin
     With Query1 do
     begin
     Close;
     SQL.Clear;
     SQL.Add(sqlStr);
     Try
      Open
     Except
      ExecSQL
     end;
     end;
    end;