Autor Beitrag
hansg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

Win XP Professional SP3, Vista Ultimate 32 SP1
Delphi 6 Professional
BeitragVerfasst: So 26.01.03 10:18 
Hallo,

ich möchte eine Listbox mit einem Eingabefeld (Edit) vergleichen, ist der Eingabetext in der Listbox vorhanden möchte ich eine Variable auf 5 setzen.

Bitte um kurze Hilfestellung.

_________________
Gruß Hans
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 26.01.03 10:30 
IndexOf.
hansg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

Win XP Professional SP3, Vista Ultimate 32 SP1
Delphi 6 Professional
BeitragVerfasst: So 26.01.03 10:39 
Upps,
habe ich mich doch glatt vertan, ich meinte eine Combobox.

_________________
Gruß Hans
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 26.01.03 10:43 
Ok, dann für eine Combobox: IndexOf.
hansg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

Win XP Professional SP3, Vista Ultimate 32 SP1
Delphi 6 Professional
BeitragVerfasst: So 26.01.03 10:59 
Hallo,
danke für den Tip aber irgendwo habe ich einen Denkfehler.
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
Var
i  : Integer;
begin
  for i:= 0 to combobox1.ItemIndex -1 do
  begin
    if combobox1.Items.IndexOf(edit1.text) > -1 then label1.Caption:='5' else label1.Caption:='0';
  end;
end;

Nur wo?

_________________
Gruß Hans
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 26.01.03 11:05 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if Combobox1.Items.IndexOf(Edit1.Text) > -1 then
    ShowMessage(IntToStr(Combobox1.Items.IndexOf(Edit1.Text)))
  else
    ShowMessage('Nicht gefunden.');
end;
hansg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

Win XP Professional SP3, Vista Ultimate 32 SP1
Delphi 6 Professional
BeitragVerfasst: So 26.01.03 12:13 
@Luckie

danke für den Code, geht supi!

_________________
Gruß Hans