Autor Beitrag
Friedhelm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Do 09.01.03 11:53 
Hallo zusammen,
ich lade in eine Memobox Namen und will sie mit dem Eintrag Edit.Text vergleichen und dann einenn Button7 freischalten.Geht.
Sobald ich mich vertippe und das EditFeld lösche, d.h. kein Text, ist der Button auch freigeschaltet - was ich nicht will.
Was mache ich falsch?

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.Edit2Change(Sender: TObject);
var i,a: Integer;

begin
    Memo1.Lines.LoadFromFile(DirectoryListBox3.Directory + '\' +  FileListBox3.Items.Strings[0]);
     Form1.Button7.Enabled := false;


        if Form1.Edit2.text <> '' then
         Form1.Button7.Enabled := false; 

     
    for a := 0 to Form1.memo1.Lines.Capacity -1 do

             if Form1.edit2.Text = Form1.memo1.Lines.Strings[a] then

      Form1.Button7.Enabled := true;
  end;


Danke für den Tip.
Gruss
Friedhelm
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Do 09.01.03 12:01 
Hi
ändere mal deine Schleife so ab:
ausblenden Quelltext
1:
for a := 0 to Form1.memo1.Lines.Count -1 do					


Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
Friedhelm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Do 09.01.03 14:03 
Hallo Lothar,

habe ich gemacht ohne Erfolg.

Das hängt doch sicher miT:

ausblenden Quelltext
1:
2:
                if Form1.Edit2.text <> '' then
         Form1.Button7.Enabled := false;


zusammen?

FRiedhelm
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Do 09.01.03 14:30 
Kommt davon, wenn man nicht richtig liest :oops:
Die Zeile kannst du eigentlich komplett löschen. Zuerst schaltest du den Button ja sowieso aus und nur bei Übereinstimmung wird er wieder aktiviert.

Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Do 09.01.03 14:34 
Hallo,

so kann das nicht funktionieren.

Versuche es einmal folgendermaßen:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.Edit2Change(Sender: TObject); 
var i,a: Integer; 

begin 
  with Memo1 do
  begin
    Lines.LoadFromFile(DirectoryListBox3.Directory + '\' +FileListBox3.Items.Strings[0]); 
    Button7.Enabled:=False; 
    if (Edit2.Text='') then Exit; // kein Eintrag im Editfeld, also tschüss
    for a := 0 to Lines.Count-1 do if (Edit2.Text=Lines.Strings[a]) then
    begin
      Button7.Enabled:=True; 
      // da Eintrag gefunden, muss Schleife nicht mehr durchlaufen werden
      Break; 
    end; // for a
  end; // with
end;

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Friedhelm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Do 09.01.03 15:12 
Hallo smiegel

das hat mir weitergeholfen.
Ist eigentlich auch klar!

vielen Dank
Gruss
Friedhelm
Friedhelm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Do 09.01.03 15:22 
Hallo smiegel

mit dem Edit "kein Eintrag" und Button "nicht aktiv" funzt.
Aber bei längeren Namen im Editfeld werden aus die in Memo1
gespeicherten Namen nicht richtig verglichen. Bei langen Namen im Editfeld wird der Button nicht freigeschaltet.
Wie kann das sein?

GRuss
Friedhelm
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Do 09.01.03 15:37 
Hallo,

es kann daran liegen, dass Du bei jeder Änderung im Editfeld das Memo mit Daten, die aus einer Datei stammen füllst.
ausblenden Quelltext
1:
Lines.LoadFromFile(DirectoryListBox3.Directory + '\' +FileListBox3.Items.Strings[0]);					

Genügt es nicht, die Daten beim Erzeugen des Fomulares zu laden?

Mit der Länge der Einträge im Edit hat das eigentlich nichts zu tun.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Friedhelm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Do 09.01.03 17:49 
Hallo smiegel,
1 mal genügt. Aber das wird so sein, das es deswegen nicht geht.
dann setze ich die Zeile:

ausblenden Quelltext
1:
 Lines.LoadFromFile(DirectoryListBox3.Directory + '\' +FileListBox3.Items.Strings[0]);					


in die create der Form.
Danke
Gruss
FRiedhelm
Friedhelm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Do 09.01.03 19:02 
Hallo smiegel

hat nicht geholfen. WEnn ich einen langen Namen eingebe, wird bereits nach dem 7. Zeichen der Button aktiv gesetzt.
Was kann man noch machen?

Gruss
Friedhelm
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Fr 10.01.03 10:06 
Hallo,

versuche es einmal damit:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Edit2Change(Sender: TObject);
var s:String;
begin
  s:=Edit2.Text;
  Button7.Enabled:=(Memo1.Lines.IndexOf(s)<>-1);
end;

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Friedhelm Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 47



BeitragVerfasst: Fr 10.01.03 13:31 
Hallo smiegel,

der Fehler ist gefunden, es ist nicht zu fassen. Das Memofeld, das ich lade, war nur klein. Eben diese 7 Zeichen.
:oops: Alles klar.
Danke.
Gruss
Friedhelm
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Fr 10.01.03 13:46 
Hallo Friedhelm,

schön, dass Du den Fehler gefunden hast. Aber trotzdem kannst Du die Routine meines vorletzten Postings benutzen.

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)