Autor Beitrag
Marco15
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Fr 13.05.05 13:10 
Hi Leute!

Ich möchte, dass wenn ich in einem editfeld den nachnamen 'Janssen' z.B. eingebe, dass eine erste listbox nach wanders durchsucht und wenn ein- oder mehrere male wanders drinsteht jeder item in einer zweiten listbox reingeschrieben wird.
ich habe das mit einem record geregelt.
er soll dann jedoch jede zeile komplett anzeigen, nicht nur wanders, also nachname + vorname+...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
type Tds = record
             vorname : string[15];
             nachname : string[20];
             telnr : string[20];
             strasse : string[25];
             stadt : string[20];
           end;


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.

_________________
Ich bin nur Schüler.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Fr 13.05.05 13:20 
Also erstmal: Du solltest deinen Quelltext mit
[delphi]
Dein Quelltext
[/delphi]
formatieren, damit der auch entsprechende Syntax hat.

Und zweitens: Wo liegt denn eigentlich das Problem genau? Beim Durchsuchen der ListBox, bei der Ausgabe aller Angaben, oder was?
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Fr 13.05.05 13:24 
also suchen habe ich schon und das problem liegt darin, dass ich jetzt wenn ich 'k' eingebe alle nachnamen die 'k' sind angezeigt werden

_________________
Ich bin nur Schüler.
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Fr 13.05.05 13:25 
In die Listbox bekommst du was mit listbox1.items.add('Dein Text');

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Fr 13.05.05 13:26 
Sollen die K angeueigt werden oder nicht. Deine Formulierung zu lesen sind nicht grad einfach.
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Fr 13.05.05 13:35 
Ok dann mach ich es nochmal mit namen.

Ich habe eine listbox in der steht:

Janssen, Paul
Gülles, Lola
Janssen, Karell

So ich gebe jetzt janssen im editfeld ein und möchte, dass er beide janssen findet und beider samt was dahinter steht in die zweite listbox reinschreibt

_________________
Ich bin nur Schüler.
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Fr 13.05.05 13:37 
Poste mal den schon vorhandenen Code, du hast gesagt du hast die suchfunktion schon

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Fr 13.05.05 13:37 
Dann mahc das doch mit ner For-Schleife, die die Strings Zeilenmäßig nach dem Suichstring durchsucht. Code folgt...
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Fr 13.05.05 13:40 
Zitat:

also suchen habe ich schon

Das Suchen hat er doch schon

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)


Zuletzt bearbeitet von Tobias1 am Fr 13.05.05 13:40, insgesamt 1-mal bearbeitet
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Fr 13.05.05 13:40 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);
var
a : integer;
begin
For a := 1 to ListBox1.Items.Count do
  begin
  if Listbox1.Items[a] = Edit1.Text then
    begin
    Listbox2.items.add(Listbox1.Items[a]);
    end;
  end;
end;


Ich mach den noch flexiebler..
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Fr 13.05.05 13:41 
sowas ?#
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
for i := 0 to listbox1.count - 1 do
  if pos(suchstring, listbox1.items[i])>0 then begin // könnte auch lines oder strings heissen
    showmessage('string gefunden in zeile ' + inttostr(i));
    break;
  end;

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Fr 13.05.05 13:42 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);
var
a : integer;
begin
For a := 1 to ListBox1.Items.Count do
  begin
  if pos(Edit1.text,ListBox1.items[a]) < 0 then
    begin
    Listbox2.items.add(Listbox1.Items[a]);
    end;
  end;
end;


EDIT: Da war ich zu langsam. Aber bracuhe ich das break; ? Er will dioch alle Namen haben.


Zuletzt bearbeitet von Fabian W. am Fr 13.05.05 13:44, insgesamt 1-mal bearbeitet
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Fr 13.05.05 13:42 
@Fabian: Listboxitem beginnt bei 0!

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Fr 13.05.05 13:44 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
for i := 0 to listbox1.count - 1 do
if pos(suchstring, listbox1.items[i])>0 then 
begin // könnte auch lines oder strings heissen
   showmessage('string gefunden in zeile ' + inttostr(i));
listbox2.items.add(listbox1.items.strings[i]);
end;


So???

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)


Zuletzt bearbeitet von Tobias1 am Fr 13.05.05 13:46, insgesamt 1-mal bearbeitet
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Fr 13.05.05 13:45 
Kommt davon wenn man mit den Gadnken schon im Urlaub is :wink: , du gast natürlich Recht.
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Fr 13.05.05 13:46 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type Tds = record
             vorname : string[15];
             nachname : string[20];
             telnr : string[20];
             strasse : string[25];
             stadt : string[20];
           end;
     Tliste = array [1..max] of Tds;
     Tdat = file of Tds;

var liste : Tliste;


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure suchen(x:Tliste);
var i:integer;
begin
for i := 1 to max do
  begin
    if x[i].nachname = form1.edit7.text then
       form1.listbox1.itemindex := i-1;

end;
end;

_________________
Ich bin nur Schüler.
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Fr 13.05.05 13:48 
Mit itenmindex wählst du das ja nur aus
du musst es einfach rüberkopieren.

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Fr 13.05.05 13:50 
@Marco: Ich hab dir den Code doch oben gepostet, Is das net das was de willst. Was soll der Code jetzt???


Fragen über Fragen...
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Fr 13.05.05 13:51 
Er hat doch schon oben geschrieben er hat die Suchfunktion

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Fr 13.05.05 13:54 
Ich habe es hingekriegt. Habe das von tobias1 ein bisschen umgeändert und jetzt funzt et.
Danke an alle die mir versucht haben zu helfen.

_________________
Ich bin nur Schüler.