
06.12.2010, 15:24
|
 |
Местный
|
|
Регистрация: 04.04.2008
Адрес: Минск
Сообщения: 596
Версия Delphi: 2007 & JAVA EE
Репутация: 10670
|
|
мой вариант, может не самый быстрый но кода мала
Код:
{структура файла
*математика
наука бла бла бла
*чайник
орудие пыток}
//На форме комбобокс и мемо
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ComboBox1: TComboBox;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var t:TStringList;
i,dlina:integer;
begin
t:=TStringList.Create;
t.LoadFromFile('1.txt');
for i:=0 to t.Count-1 do
begin
dlina:=length(t[i]);
if t[i][1]='*' then ComboBox1.Items.Add(copy(t[i],2,dlina-1));
end;
t.Free;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var t:TStringList;
i,dlina:integer;
begin
t:=TStringList.Create;
t.LoadFromFile('1.txt');
for i:=0 to t.Count-1 do
begin
if (t[i])=('*'+ComboBox1.Text) then memo1.Text:=t[i+1];
end;
t.Free;
end;
end.
:
Вот проект:
__________________
Последний раз редактировалось Admin, Сегодня в 10:32.
|