Autor Beitrag
kronoide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: So 21.01.07 20:59 
Hallo erstmal :D
ich bin noch relativ neu in Delphi und wollte mal fragen
wie man den string im edit.text, in der listbox prüfen lässt ob der da vorhanden ist und
wenn, dann soll er etwas ausführen. Ein Code-Beispiel währe net.


Moderiert von user profile iconChristian S.: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am So 21.01.2007 um 21:08
zongo-joe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 134

win xp prof
D3, D4, D7
BeitragVerfasst: So 21.01.07 21:13 
zB so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i:=1 to listbox.items.count do
  if edit.text = listbox.items[i-1] then begin // i-1, weil in Listbox erster Index 0 ist
    // Aktion
end;
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 21.01.07 21:13 
Hallo!

Ob ein Text in der Listbox enthalten ist, bekommst über listbox1.Items.IndexOf(deinText) raus. Wenn der Text drin vorkommt, gibt IndexOf den entsprechenden Index in der Listbox zurück, kommt der String nicht darin vor, gibt Indexof den Wert -1 zurück.

Das ganze noch in eine if-Abfrage packen und Du bist im Rennen. Wenn Du nicht weißt, wie das geht, kann ich Dir meinen Crashkurs Delphi empfehlen.

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
zongo-joe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 134

win xp prof
D3, D4, D7
BeitragVerfasst: So 21.01.07 21:16 
ok christian - is flotter !
kronoide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: So 21.01.07 21:18 
vielen dank ihr tollen leut :party: