Entwickler-Ecke

Grafische Benutzeroberflächen (VCL & FireMonkey) - In einem Editfeld Suchen


BlackRaven - Sa 25.10.03 02:18
Titel: In einem Editfeld Suchen
Ich möche bei einem OnKeyPress Ereihbis nach Key=#13 suchen ob ein bestimmter string im Editfeld steht. Wie mache ich das?


Delete - Sa 25.10.03 03:55

Suche in: Delphi-Forum, Delphi-Library POS Und alle damit zusammenhängenden Stringfunktionen.


BlackRaven - Sa 25.10.03 13:10

ich hab das jetzt so realisiert.
aber dafür müsste es doch noch eine einefachere Lösung geben:

Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
var
  LinkE: Boolean;
  LinkD: Boolean;
  Link2: Boolean;
  LinkK: Boolean;
  Linkdp: Boolean;
begin
if Key=#13 then
  begin
//erstmal schauen ob es ein ed2k link ist->start
  if pos('e',ComboBox1.Text)=1 then LinkE:=true else if pos('E',ComboBox1.Text)=1 then LinkE:=true;
  if pos('d',ComboBox1.Text)=2 then LinkD:=true else if pos('D',ComboBox1.Text)=2 then LinkD:=true;
  if pos('2',ComboBox1.Text)=3 then Link2:=true;
  if pos('k',ComboBox1.Text)=4 then LinkK:=true else if pos('K',ComboBox1.Text)=4 then LinkK:=true;
  if pos(':',ComboBox1.Text)=5 then Linkdp:=true;
  if (LinkE and LinkD and Link2 and LinkK and Linkdp)=true then Showmessage('ED2K Link');
  if (LinkE and LinkD and Link2 and LinkK and Linkdp)=true then ed2k.CheckListBox1.Items.Add(ComboBox1.Text);
//erstmal schauen ob es ein ed2k link ist->ende
end;


JoelH - Sa 25.10.03 13:24
Titel: hmm,

Delphi-Quelltext
1:
2:
3:
4:
5:
  if pos('e',ComboBox1.Text)=1 then LinkE:=true else if pos('E',ComboBox1.Text)=1 then LinkE:=true; 
  if pos('d',ComboBox1.Text)=2 then LinkD:=true else if pos('D',ComboBox1.Text)=2 then LinkD:=true; 
  if pos('2',ComboBox1.Text)=3 then Link2:=true; 
  if pos('k',ComboBox1.Text)=4 then LinkK:=true else if pos('K',ComboBox1.Text)=4 then LinkK:=true; 
  if pos(':',ComboBox1.Text)=5 then Linkdp:=true;


kannste abkürzen =>


Delphi-Quelltext
1:
 if POS('ED2K:',UPPERCASE(edit1.text)) = 1 then edit2.Text := 'iss an erster Stelle';                    


BlackRaven - Sa 25.10.03 13:30

thx, das sieht schonmal gut aus, ich probiers morgen früh aus, ich muss jetzt auf arbeit
vielen dank nochmal