delphi6BDE
Programmer
During a larger procedure, I have a multi-select listbox that loads a list of flagged items. this list of flagged items needs to be looped twice to determine what is selected, and what is not selected and hopefully give me two SQL outputs on each pass; when selected, give me an in clause like '
SQL:
In ('item1', 'item2')
SQL:
not in ('item3')
I'm able to loop and output what has been selected, but not what is not selected. Does anybody know how to finish my sample code into what I'd like to do?
Hopefully I'm making sense here with my question, but if clarification is needed, please ask and I'll try my best to walk you though with more detail.
I would like the results of the loops to be:
Select sample (nothing should be selected at beginning of loop):
pass 1:
SQL:
in ('') and not in ('item1', 'item2', 'item3')
SQL:
in ('item1') and not in ('item2', 'item3')
SQL:
in ('item1', 'item2') and not in ('item3')
Deselect sample (all items should be selected at beginning of loop):
pass 1:
SQL:
not in ('') and in ('item1', 'item2', 'item3')
SQL:
not in ('item1') and in ('item2', 'item3')
SQL:
not in ('item1', 'item2') and in ('item3')
Sort of working so far:
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
vSel: string;
begin
for i := 0 to Listbox1.Items.Count -1 do
begin
Listbox1.Selected[i]:=true;
vSel:=vSel + QuotedStr(Listbox1.Items[i]) + ', ';
//trim last comma
//vSel:=Copy(vSel, 0, Length(vSel) -2);
Memo1.Lines.Add(vSel);
if Listbox1.Selected[i] = false then
Memo1.Lines.Add(inttostr(i));
end;
end;