如何遍历集合中的元素! ( 积分: 50 )

  • 主题发起人 主题发起人 linghu
  • 开始时间 开始时间
L

linghu

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在已经连接到数据库,但是我想取得ADOCONNECTION的state值,怎样实现?
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1937809
如何遍历一个集合?

http://www.delphibbs.com/delphibbs/dispq.asp?lid=3438514
如何遍历一个集合

http://www.delphibbs.com/delphibbs/dispq.asp?lid=2650674
请问如何枚举一个集合里和每个元素

----------------------------

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
type
TSets = set of (ssA, ssB, ssC, ssD);

function GetSetCount(const V): Byte;
var
D: Byte;
begin
Result := 0;
D := PByte(@V)^;
while D <> 0 do begin
if D and 1 = 1 then
Inc(Result);
D := D shr 1;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
V: TSets;
begin
V := [ssA, ssB, ssD];
Caption := IntToStr(GetSetCount(V));
end;

end.
 
if state in 集合名称 then
......
 
后退
顶部