現有兩個欄位client 字符型,htflag 布爾型
如果client有相同的記錄那么htflag自動打鉤
uj5u.com熱心網友回復:
思路大概這樣:先回圈找到client值相同的記錄起來(可以放到陣列中,也可以放到TStringList里面),然后再走回圈對htflag打勾。uj5u.com熱心網友回復:
先把有重復記錄的資料篩選出來,再來取一次資料就行了。或者每次都判斷uj5u.com熱心網友回復:
for i := 0 to lstClient.count - 1 dobegin
if not lsthtflag[i] then
beging
for j:=i to lstClient.Count - 1 do
begin
if lstClient[i]=lstClient[j] then
begin
lsthtflag[i]:= true;
lsthtflag[j]:= true;
break;
end;
end;
end;
end;
uj5u.com熱心網友回復:
1、將需要處理的資料讀入DBGrid1中;2、執行以下代碼:
procedure TMedicineInOutFrm.Button45Click(Sender: TObject);
var S:string;
A:array of array [0..1] of String;
Top,I,J:integer;
T:boolean;
begin
with DBGrid1.DataSource.DataSet do
begin
First;
Top:=0;
while Not Eof do
begin
S:=FieldByName('client').asString;
if S<>'' then
begin
SetLength (A, Top+1);
A[Top,0]:=S;
Top:=Top+1;
end;
Next;
end;
end;
for I:=0 to Top-1 do
for j:=0 to Top-1 do
if I<>j then
if A[i,0]=A[j,0] then A[i,1]:='1';
with DBGrid1.DataSource.DataSet do
begin
First;
while Not Eof do
begin
T:=False;
S:=FieldByName('client').asString;
for I:=0 to Top-1 do
if A[i,0]=S then
if A[i,1]='1' then T:=True;
Edit;
FieldByName('htflag').asBoolean:=T;
Post;
Next;
end;
end;
end;
uj5u.com熱心網友回復:

LS的代碼,不明覺厲啊
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/98925.html
標籤:語言基礎/算法/系統設計
