标签:
var
Dict:Variant;
n,ncount,i:byte;
kArr,iArr:array of variant;
Ts,Ts2:TStringList;
kv,iv,FGF:string;
procedure TForm1.Button1Click(Sender: TObject);
begin
Dict:= CreateoleObject(‘scripting.dictionary‘);
Ts:=tstringlist.Create; Ts2:=tstringlist.Create;
Ts.LoadFromFile(‘dat.txt‘);
ncount:=ts.count-1;
FGF:=‘◆‘;
for n:=1 to ncount do
begin
Ts2.Delimiter:=‘,‘ ;
Ts2.DelimitedText:=Ts[n];
kv:=ts2[0];
iv:=ts2[1]+FGF+ts2[2]+FGF+ts2[3]+FGF+ts2[4]+FGF+ts2[5];
Dict.add(kv,iv);
end;
Ts.free; Ts2.Free;
ncount:=dict.count-1;
setlength(kArr,ncount); setlength(iArr,ncount);
kArr:=dict.keys; iArr:=dict.items;
dict.RemoveAll;
dict:=‘‘;
meo.Clear;
for n:=0 to ncount do
begin
meo.Lines.Add(‘Key:‘+kArr[n]+‘ ┃ ‘+‘Item:‘+iArr[n]);
meo.Lines.Add(‘‘);
end;
{ 释放数组方法:2种 }
kArr:=nil; {nil:无;零;虚无;空类型;不存在的 }
Finalize(iArr); { Finalize:完成;使结束;把…最后定下来 }
end;
输出结果:
delphi使用VB的dictionary对象
标签:
原文地址:http://www.cnblogs.com/lvyangyinli/p/5255097.html