Autor Beitrag
sealouce
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Sa 06.09.08 19:10 
HAllo

Ich bin neu hier und komme bei einem Projekt nicht weiter

nun ja , ich habe 3 Listboxen und hätte gerne den Inhalt in Listbox3 der nur in einer von den beiden anderen Listboxen ist.

Bsp

Listbox1

Aal
Tiger
Wal
Hai
Wolf
Eule
Igel

Listbox2
Aal
Tiger
Hai
Eule

dann möhte ich in Listbox3 nur

Wal, Igel und Wolf haben.


Das habe ich schonmal zusammen gecodet funzt aber nicht so wies soll, wüsste gern wo der Fehler ist


Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
begin


    s:=Listbox1.Items;
   begin
      if (ListBox2.Items.IndexOf(s) = -1then
        begin
        ListBox3.Items.Add(s);
        end;
      end;
   end;


Danke im vorraus für Hilfe.[delphi]


Moderiert von user profile iconNarses: Topic aus Dateizugriff verschoben am So 07.09.2008 um 23:03
wazup
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 101

Windows XP
Delphi 2009
BeitragVerfasst: Sa 06.09.08 19:26 
user profile iconsealouce hat folgendes geschrieben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
begin


    s:=Listbox1.Items;
   begin
      if (ListBox2.Items.IndexOf(s) = -1then
        begin
        ListBox3.Items.Add(s);
        end;
      end;
   end;
Würd mal ganz klar sagen S := ListBox1.Items
sealouce Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Sa 06.09.08 19:30 
uuuuuund was muss ich da ändern ^^
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 06.09.08 19:58 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
begin
  for i := 0 to ListBox1.Items.Count - 1 do
    begin
      if (ListBox2.Items.IndexOf(ListBox1.Items[i])=-1then
        ListBox3.Items.Add(ListBox1.Items.Strings[i]);
    end;
end;

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
sealouce Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Sa 06.09.08 20:14 
Wär ja zu schön um war zu sein, aber der Code funzt leider nicht :cry:
Wenn ich das Stückchen code hätte käme ich mit meinem MÖCHTEGERN Antivirus echt weiter.
Naja zumindest soll das Programm zu jeden Start alle ExeFiles zählen und diese dann speichern.
Bei erneuten öffnen soll es die ExeFiles auf dem Pc mit der gespeicherten Liste vergleichen und auch neue Dazeien anzeigen.
So will ich sicherstellen, dass sich keine schädlichen Programme unbemerkt auf dem Rechner installieren.
Deshalb vrauche ich den Code.



Ach ja bevor ichs vergesse, weiß nicht ob das ne Rolle spielt aber ich arbeite mit Delphi 5.
wazup
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 101

Windows XP
Delphi 2009
BeitragVerfasst: Sa 06.09.08 20:16 
Du solltest vllt. auch die Fehlermeldung Posten, und einen Crashkurs machen
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Sa 06.09.08 21:35 

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
sealouce Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Mo 08.09.08 10:44 
Das isses ja da, kommt keine Fehlermeldung und ich denke nicht das es am begin und end liegt sorry ^^
Es bleibt einfach nur die Listbox leer. Ich schick ma den ganzen Quellcode
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Label1: TLabel;
    Memo1: TMemo;
    Label2: TLabel;
    LBzahl: TLabel;
    LBzahl1: TLabel;
    Lbgreen: TLabel;
    ListBox2: TListBox;
    LBYellow1: TLabel;
    LBYellow2: TLabel;
    ListBox3: TListBox;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
    nFileCount : integer;

implementation




procedure GetFilesInDirectory(Directory: stringconst Mask: string;
                              List: TStrings;
                              WithSubDirs, ClearList: Boolean);

procedure ScanDir(const Directory: string);
var
  SR: TSearchRec;
begin
  if FindFirst(Directory  + Mask, faAnyFile and not faDirectory, SR) = 0 then try
    repeat
      List.Add(Directory + SR.Name)
    until FindNext(SR) <> 0;
  finally
    FindClose(SR);
  end;

  if WithSubDirs then begin
    if FindFirst(Directory + '*.*', faAnyFile, SR) = 0 then try
      repeat
        if ((SR.attr and faDirectory) = faDirectory) and
           (SR.Name <> '.'and (SR.Name <> '..'then
          ScanDir(Directory + SR.Name + '\');
      until FindNext(SR) <> 0;
    finally
      FindClose(SR);
    end;
  end;
end;

begin
  List.BeginUpdate;
  try
    if ClearList then
      List.Clear;
    if Directory = '' then Exit;
    if Directory[Length(Directory)] <> '\' then
      Directory := Directory + '\';
    ScanDir(Directory);
  finally
    List.EndUpdate;
  end;
end;

{$R *.DFM}


procedure TForm1.FormCreate(Sender: TObject);
var F:textfile;
var zahl, zahl2, zahl3 , i, x :integer;


begin
GetFilesInDirectory('C:\','*.exe', Listbox1.Items, true,false);
Lbzahl.caption:= IntToStr (Listbox1.items.count);
zahl:=Listbox1.items.count;



if FileExists ('C:\Anzahl.txt'then
try
    memo1.lines.Loadfromfile('C:\Anzahl.txt');
    LBzahl1.caption:=memo1.lines[0];
    EXCEPT
       ShowMessage ('Fehler beim Laden der Datei!');
 end;

zahl2:=strtoint(lbzahl1.caption);

if zahl = zahl2 then
begin
 LBgreen.visible:=true;
end

 else if zahl > zahl2 then
 begin
 form1.top:=650;
 form1.height:=305;
 listbox3.visible:=true;
 Zahl3:=zahl-zahl2;
 LBYellow1.visible:=true;
 LBYellow1.caption:=inttostr(zahl3);
 LBYellow2.visible:=true;
 ListBox2.Items.LoadFromFile('C:\ExeFiles.txt');

  for i := 0 to ListBox1.Items.Count - 1 do
    begin
      if (ListBox2.Items.IndexOf(ListBox1.Items[i])=-1then
        ListBox3.Items.Add(ListBox1.Items.Strings[i]);
    end;

  end


 else if zahl < zahl2 then
 begin

 end;



if not FileExists ('C:\Exefiles'then

begin
  AssignFile(F, 'C:\ExeFiles.txt');
  {$i-}
  Rewrite(F);

FOR x := 0 TO ListBox1.Items.Count-1 DO
             Writeln (F, ListBox1.Items[x]);
    CloseFile(F);
  {$I+}
end;

if not FileExists ('C:\Anzahl.txt'then
begin
  AssignFile(F, 'C:\Anzahl.txt');
  {$i-}
  rewrite(f);
  Writeln(F, zahl);
    {$I+}
closefile(f);
end;




end;

end.



Moderiert von user profile iconGausi: Doppelpost auf Grund Verwechslung von Edit- und Quote-Button entfernt.
sealouce Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Mo 08.09.08 19:22 
ich hab mein Programm fertig sry Blackheart666 dein Code war richtig der fehler war wo anders :) Ich kann das Programm ja zum download hier reinstellen