26.12.2006, 08:06
общий
это ответ
Здравствуйте, Костенко Игорь Викторович!
Вот примерно какой код у меня получилься (см. Приложение)
Ф-я ExtractDate разбивает дату на день, месяц, год
(можно в отдельную ф-ю не делать, но я для удобства вынес).
УДАЧИ
Приложение:
...uses...;Type E_Date=record Day: Integer; Month: Integer; Year: Integer;end;type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Button1: TButton; procedure Button1Click(Sender: TObject); Function ExtractDate(S_Date: TDateTime): E_Date; private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);var Age: integer; Tmp: E_Date;begin Tmp:=ExtractDate(Date); Age:=Tmp.Year-StrToInt(Edit3.Text); if(StrToInt(Edit2.Text)>=Tmp.Month) and(StrToInt(Edit1.Text)>Tmp.Day) then Age:=Age-1; showmessage(inttostr(Age));end;Function TForm1.ExtractDate(S_Date: TDateTime): E_Date;var Str: String;begin Str:=DateToStr(S_Date); if Length(Str)=9 then Result.Day:=StrToInt(Copy(Str,1,1)) else Result.Day:=StrToInt(Copy(Str,1,2)); Result.Month:=StrToInt(Copy(Str,Length(Str)-6,2)); Result.Year:=StrToInt(Copy(Str,Length(Str)-3,4));end;end.