发信人: delphifan()
整理人: teleme(2001-04-04 15:30:25), 站内信件
|
如何计算任意一个月份的天数呢?
function TForm1.DaysInMonth(ADate:TDateTime):Integer;
var
MyMonth,
MyYear,
MyDay : Word;
MyDayTable : TDayTable;
tmpBool : Boolean;
begin
DecodeDate(ADate, MyYear, MyMonth, MyDay);
tmpBool := IsLeapYear(MyYear);
MyDayTable := MonthDays[tmpBool];
Result := MyDayTable[MyMonth];
end;
procedure TForm1.Button1Click(Sender: TObject);
var
MyDate : TDateTime;
tmpStr : String;
tmpInt : Integer;
begin
MyDate := Date() + 365 - (30*5);
tmpStr := FormatDateTime('mmmm yyyy',MyDate);
tmpInt := DaysInMonth(MyDate);
ShowMessage(tmpStr + '有 ' + IntToStr(tmpInt) + '天');
end;
-- =================================================
== [email protected] ==
== [一个真正有内容、较实用的Delphi网站] ==
== http://lmd.yeah.net http://lmd.126.com ==
=================================================
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.100.18.226]
|
|