各位請幫忙一個忙,,
就是怎麼知道一個月有多少天,就拿2月來說,比如說現在是2號怎麼知道這個月就只有28天呢
請給出一個詳細的過程好嗎???
希望是完整的代碼

解决方案 »

  1.   

    function LastDayOfMonth(Dat: TDate): TDate;varD, M, Y : Word;beginDecodeDate(IncMonth(Dat, 1), Y, M, D);Result := EncodeDate(Y, M, 1) - 1;end;
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,DateUtils;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}
    function LastDayOfMonth(Dat: TDate): TDate;varD, M, Y : Word;beginDecodeDate(IncMonth(Dat, 1), Y, M, D);Result := EncodeDate(Y, M, 1) - 1;end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      showmessage(inttostr(dayOf(LastDayOfMonth('2003-09-09'))));end;end.
      

  3.   

    [Error] Unit1.pas(40): Incompatible types: 'TDate' and 'String'
      

  4.   

    var
      i:integer;
    begin
      i:=DaysInMonth(now());
     showmessage(inttostr(i));
    end;
      

  5.   

    : lion_lh(xmanx)
    linzhisong(無聊) 
    謝謝。。
      

  6.   

    uses dateutils
    中的
    DaysInMonth(Date)