Monday, June 16, 2008

Delphi foreach (COM) implementation

Comlib (http://www.techvanguards.com/com/resources/downloads.asp) has an implementation of the foreach construct (used in COM Automation). Example:
var
r : OleVariant; // range
c : OleVariant; // cell
Enum : TEnumVariant;

begin
Enum := TEnumVariant.Create(r);
while(Enum.ForEach(c)) do begin
....do something with c...
end;
end;
Some minor edits are needed for Delphi 2007.

No comments:

Post a Comment