关于星期六、星期天的判断(50分)

  • 主题发起人 主题发起人 chur
  • 开始时间 开始时间
C

chur

Unregistered / Unconfirmed
GUEST, unregistred user!
请问在MonthCalendar,我怎么判断那一天是星期六、星期天?怎么把一年的都列出来?
 
DayOfWeek

var
ADate: TDateTime;
days: array[1..7] of string;
begin
days[1] := 'Sunday';
days[2] := 'Monday';
days[3] := 'Tuesday';
days[4] := 'Wednesday';
days[5] := 'Thursday';
days[6] := 'Friday';
days[7] := 'Saturday';
ShowMessage('Today is a ' + days[DayOfWeek(Date)]);
end;
 
那怎么算从今天开始到年底呢?循环如何表示?

for 今天 to 年底 do
begin
k:=dayofweek(日期);
end;

写成程序是什么?谢谢!
 
var
y,m,d: word;
i: Integer;
begin
decodedate(now, y, m, d);
inc(y);
m := 1;
d := 1;
for i := 1 to round(int(encodedatetime(y, m, d))-int(now)) do
k := dayofweek(now+i-1);
end;
 
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
ShortDateFormat := 'yyyy-mm-dd';
for i := Trunc(Now) to Trunc(StrToDate(FormatDateTime('yyyy', Now) + '-12-21')) do
begin
if dayofweek(i) = 7 then
ListBox1.Items.Add(DateToStr(i));
end;
end;
 
procedure TMainForm.FormCreate(Sender: TObject);
var
ADate: TDateTime;
days: array[1..7] of string;
Year, Month, Day: Word;

begin
days[1] := '星期日';
days[2] := '星期一';
days[3] := '星期二';
days[4] := '星期三';
days[5] := '星期四';
days[6] := '星期五';
days[7] := '星期六';
ADate:= date();
DecodeDate(adate, Year, Month, Day);
StatusBar1.Panels[1].Text := ' '+inttostr(Year)+ '年'+ inttostr(Month) +'月'+inttostr(Day)+'日 ' + days[DayOfWeek(ADate)];
end;
 
接受答案了.
 
后退
顶部