Поиск в списке любого слова или буквы
Автор: Лагуткин Денис
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a: Integer = 0;
implementation
{$R *.dfm}
function UpCaseAll(x: string): string;
var
b, w: integer;
str: string;
begin
for w := 1 to length(x) do
begin
b := ord(x[w]);
case b of
0..96: x[w] := chr(b);
97..122: x[w] := UpCase(chr(b));
123..183: x[w] := chr(b);
184: x[w] := chr(168);
185..223: x[w] := chr(b);
224..255:
begin
b := b - (Ord('а') - Ord('А'));
x[w] := chr(b);
end;
end;
str := str + x[w];
end;
UpCaseAll := str;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
st, st1: string;
f, i: integer;
begin
st := UpCaseAll(Edit1.Text);
if st <> '' then
begin
for i := a to listbox1.Count - 1 do
begin
st1 := UpCaseAll(Listbox1.Items.Strings[i]);
repeat
f := POS(st, st1);
if f <> 0 then
begin
Listbox1.ItemIndex := i;
a := i + 1;
exit;
end;
until f = 0;
end;
a := 0;
end;
end;
end.
|