delphi for 遍历用法  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi for 遍历用法



示例代码:Integer for循环

var

  i : Integer;


begin

  // Loop 5 times

  For i := 1 to (10 div 2) do

    ShowMessage('i = '+IntToStr(i));

end;

Show full unit code

   i = 1

   i = 2

   i = 3

   i = 4

   i = 5

 

示例代码:循环字符

var

  c : char;

begin

  // Loop 5 times - downwards

  For c := 'E' downto 'A' do

    ShowMessage('c = '+c);

end;

Show full unit code

   c = E

   c = D

   c = C

   c = B

   c = A

 

示例代码:循环枚举

var

  suit : (Hearts, Clubs, Diamonds, Spades);

begin

  // Loop 3 times

  For suit := Hearts to Diamonds do

    ShowMessage('Suit = '+IntToStr(Ord(suit)));

end;

Show full unit code

   Suit = 0

   Suit = 1

   Suit = 2



推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.068521022796631 seconds