不能设置!
可以变通一下:
for i:=1 to 20 do
  begin
    if (i mod 2)=1
      then ...
  end;
这样步长就为2了

解决方案 »

  1.   

    怎么不可能!delphi help中for 语句的定义如下:
    The syntax of a for statement isfor counter := initialValue to finalValue do statementorfor counter := initialValue downto finalValue do statement
      

  2.   

    delphi就是这样:)
    不服气可以去信骂inprise:)
      

  3.   

    自己在for内部counter:=counter+步长-1可不可以?
      

  4.   

    不行:delphi4.0 up
    counter is a local variable (declared in the block containing the for statement) of ordinal type, without any qualifiers.
    initialValue and finalValue are expressions that are assignment-compatible with counter.
    statement is a simple or structured statement that does not change the value of counter.
    counter不能改变.
      

  5.   

      如果你是用counter := counter + 步长 - 1 那还不如用while循环呢。
      for 循环实际上是while循环的一种特例,对计数器作了优化(用了CPU的寄存器)。
    如真想用for循环,可如此:
      for counter := 0 to (finalValue - initialValue) div step do statement
      

  6.   

    >>用counter := counter + 步长 - 1 
    在delphi4.0以上根本不能用,编译错误.
      

  7.   

    是可以变通一下,eg:
    for i:=0 to 20 do
       begin
         j:=i mod 2;
         if j<>0 then
           break
         else
          //do your job    实现步长2;
       end;
      

  8.   

    如果使用这种循环来进行线性处理的话,那么电影将是15FPS。不是教学演示for用途的话,干吗不采用大家建议的用while代替for的方法呐?:)
      

  9.   

       说for步长为1, 其实是pascal的问题。在pascal中,为保证其结构性和模块性,规定for循环的步长为1。如果Delphi允许步长为一个不为1的值,就有违初衷了(Delphi就不Delphi了,而是C++了)。
       其实,在pascal中,修改for循环变量值是不明智的,因为有些pascal的编译程序在循环开始时已经算出了循环的次数,改了也没用的(好象在Delphi中也是这样)。
       如果确实需要步长不为1,在pascal中还有repeat .. until和 while 两个语句来完成用户的需要。不一定要用for。