var
daynumber:integer;
Year, Month;
begin
daynumber :=MonthDays(Year,Month);
end;
[Pascal Error] uSearchfrm.pas(257): E2066 Missing operator or semicolon
[Pascal Error] uSearchfrm.pas(257): E2010 Incompatible types: 'Integer' and 'Array'
daynumber:integer;
Year, Month;
begin
daynumber :=MonthDays(Year,Month);
end;
[Pascal Error] uSearchfrm.pas(257): E2066 Missing operator or semicolon
[Pascal Error] uSearchfrm.pas(257): E2010 Incompatible types: 'Integer' and 'Array'
解决方案 »
- cxdbtreeview如何取得父节点
- ComboBox的使用
- delphi中 ctrl+空格 的问题,在线等待!!
- 关于DELPHI 子窗口的问题
- 散尽所有的分求答案
- 晕…!把123456.63写入表中,存的却是123456.74,字段类型是decimal(15,2),哪错了???
- 搞不懂,按下button为何没有反应?
- TTreeView
- zswang(伴水)(伤心中)老大,请速至http://www.csdn.net/expert/topic/378/378407.shtm有事请教
- 关于sql的问题啊,很急!~~~~~~~~~~~
- 简单问题,困扰很久,请各位帮忙
- 现在想用delphi7开发英文版的软件,诸位有何高见?
daynumber:integer;
begin
daynumber :=MonthDays(YearOf(Date),MonthOf(Date));
end;
function DaysInAMonth(const AYear, AMonth: Word): Word;
MonthDays[False][Month]
其中第一个下标取是否为闰年,第二个下标是第几个月
const
MonthDays: array [Boolean] of TDayTable =
((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));不知道楼主真正需要的是不是DateUtils单元当中定义的DaysInAMonth?
function DaysInMonth(const AValue: TDateTime): Word;
var
LYear, LMonth, LDay: Word;
begin
DecodeDate(AValue, LYear, LMonth, LDay);
Result := DaysInAMonth(LYear, LMonth);
end;function DaysInAMonth(const AYear, AMonth: Word): Word;
begin
Result := MonthDays[(AMonth = 2) and IsLeapYear(AYear), AMonth];
end;
uses DateUtils;procedure TForm1.Button1Click(Sender: TObject);
var
daynumber:integer;
Year, Month: word; // Year, Month 变量要指定类型
begin
// MonthDays 是二维数组,可以这样使用
daynumber :=MonthDays[false,2]; //2月份有28天
// 或 :
daynumber :=MonthDays[true,2]; //2月份有29天
//你可能要的是:
Year:=2009;
Month:=12;
daynumber := DaysInAMonth(year, month);
showmessage('2009年12月有'+inttostr(daynumber)+'天');
end;