Q:如何以計算欄位顯示某人目前的年齡? A:參考下面的程式碼: function CalculateEmployeeAge(Value: TDateTime): Integer; var CurYear: Word; CurMonth: Word; CurDay: Word; BirthYear: Word; BirthMonth: Word; BirthDay: Word; begin Result:=0; if (Value <> 0) then begin DecodeDate(Date,CurYear,CurMonth,CurDay); DecodeDate(Value,BirthYear,BirthMonth,BirthDay); if (CurMonth > BirthMonth) then Result:=CurYear-BirthYear else if (CurMonth=BirthMonth) then begin if (CurDay >= BirthDay) then Result:=CurYear-BirthYear else Result:=CurYear-BirthYear-1; end else Result:=CurYear-BirthYear-1; end; end;