如何用Calendar1抓取一個月的某一星期所有天數的值??? |
|
y2464372001
一般會員 ![]() ![]() 發表:6 回覆:7 積分:2 註冊:2007-01-23 發送簡訊給我 |
|
pcboy
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
procedure TForm1.AllDaysOfWeek(Year: Integer; Month: Integer; Week: Integer);
begin Calendar1.Year := Year; Calendar1.Month := Month; Memo1.Lines.Add(Calendar1.CellText[0,week]); Memo1.Lines.Add(Calendar1.CellText[1,week]); Memo1.Lines.Add(Calendar1.CellText[2,week]); Memo1.Lines.Add(Calendar1.CellText[3,week]); Memo1.Lines.Add(Calendar1.CellText[4,week]); Memo1.Lines.Add(Calendar1.CellText[5,week]); Memo1.Lines.Add(Calendar1.CellText[6,week]); end; procedure TForm1.FormCreate(Sender: TObject); begin Memo1.Clear; AllDaysOfWeek(2006,1, 2); // 印出 2006 年 1 月第 2 周所有日子 end;
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案! 子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問! |
pcboy
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
void __fastcall AllDaysOfWeek(int Year, Month, Week) // E2303 Type name expected 錯誤, 恕小弟 BCB 不精, 不知如何修正這行, 但是架構大致如此
{ CCalendar1->Year = Year; CCalendar1->Month = Month; Memo1->Lines->Add(CCalendar1->CellText[0,week]); Memo1->Lines->Add(CCalendar1->CellText[1,week]); Memo1->Lines->Add(CCalendar1->CellText[2,week]); Memo1->Lines->Add(CCalendar1->CellText[3,week]); Memo1->Lines->Add(CCalendar1->CellText[4,week]); Memo1->Lines->Add(CCalendar1->CellText[5,week]); Memo1->Lines->Add(CCalendar1->CellText[6,week]); } void __fastcall TForm1::FormCreate(TObject *Sender) { Memo1->Clear; AllDaysOfWeek(2006,1, 2); // 印出 2007 年 1 月第 2 周所有日子 }
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案! 子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問! |
coa
一般會員 ![]() ![]() 發表:1 回覆:16 積分:13 註冊:2004-07-18 發送簡訊給我 |
|
pcboy
版主 ![]() ![]() ![]() ![]() ![]() ![]() 發表:177 回覆:1838 積分:1463 註冊:2004-01-13 發送簡訊給我 |
請 coa 再指點一下
void AllDaysOfWeek(int Year, int Month, int Week) 會有下面錯誤 [C Error] Unit1.cpp(21): E2451 Undefined symbol 'CCalendar1' [C Error] Unit1.cpp(24): E2451 Undefined symbol 'Memo1' [C Error] Unit1.cpp(24): E2451 Undefined symbol 'week' [C Error] Unit1.cpp(35): E2235 Member function must be called or its address taken void TForm1::AllDaysOfWeek(int Year, int Month, int Week) 會有下面錯誤 [C Error] Unit1.cpp(20): E2316 'TForm1::AllDaysOfWeek(int,int,int)' is not a member of 'TForm1' [C Error] Unit1.cpp(35): E2235 Member function must be called or its address taken [C Error] Unit1.cpp(36): E2268 Call to undefined function 'AllDaysOfWeek' void __fastcallTForm1::AllDaysOfWeek(int Year, int Month, int Week) 會有下面錯誤 [C Error] Unit1.cpp(20): E2316 '_fastcall TForm1::AllDaysOfWeek(int,int,int)' is not a member of 'TForm1' [C Error] Unit1.cpp(35): E2235 Member function must be called or its address taken [C Error] Unit1.cpp(36): E2268 Call to undefined function 'AllDaysOfWeek' 全文如下, 使用 BCB 6.0 Enterprise //--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "CCALENDR" #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void AllDaysOfWeek(int Year, int Month, int Week) { CCalendar1->Year = Year; CCalendar1->Month = Month; Memo1->Lines->Add(CCalendar1->CellText[0][week]); Memo1->Lines->Add(CCalendar1->CellText[1][week]); Memo1->Lines->Add(CCalendar1->CellText[2][week]); Memo1->Lines->Add(CCalendar1->CellText[3][week]); Memo1->Lines->Add(CCalendar1->CellText[4][week]); Memo1->Lines->Add(CCalendar1->CellText[5][week]); Memo1->Lines->Add(CCalendar1->CellText[6][week]); } void __fastcall TForm1::FormCreate(TObject *Sender) { Memo1->Clear; AllDaysOfWeek(2006,1, 2); // 印出 2006 年 1 月第 2 周所有日子 } //---------------------------------------------------------------------------
------
能力不足,求助於人;有能力時,幫幫別人;如果您滿意答覆,請適時結案! 子曰:問有三種,不懂則問,雖懂有疑則問,雖懂而想知更多則問! |
coa
一般會員 ![]() ![]() 發表:1 回覆:16 積分:13 註冊:2004-07-18 發送簡訊給我 |
pcboy2大您好:
很抱歉沒寫清楚... void AllDaysOfWeek(int Year, int Month, int Week) { TCCalendar *cal = Form1->CCalendar1; TStrings *weekday_list = Form1->Memo1->Lines; cal->Year = Year; cal->Month = Month; weekday_list->Add(cal->CellText[0][Week]); weekday_list->Add(cal->CellText[1][Week]); weekday_list->Add(cal->CellText[2][Week]); weekday_list->Add(cal->CellText[3][Week]); weekday_list->Add(cal->CellText[4][Week]); weekday_list->Add(cal->CellText[5][Week]); weekday_list->Add(cal->CellText[6][Week]); } 如果要改成可以直接使用元件名稱的話... 程式碼需改成: //修改 {source_code}.h 檔 class TForm1 : public TForm { __published: // IDE-managed Components TCCalendar *CCalendar1; TMemo *Memo1; void __fastcall AllDaysOfWeek(int Year, int Month, int Week); //把這一行加進去 private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); }; //原始碼不用改 //void AllDaysOfWeek(int Year, int Month, int Week)==>改成 void __fastcall TForm1::AllDaysOfWeek(int Year, int Month, int Week) { CCalendar1->Year = Year; CCalendar1->Month = Month; Memo1->Lines->Add(CCalendar1->CellText[0][Week]); Memo1->Lines->Add(CCalendar1->CellText[1][Week]); Memo1->Lines->Add(CCalendar1->CellText[2][Week]); Memo1->Lines->Add(CCalendar1->CellText[3][Week]); Memo1->Lines->Add(CCalendar1->CellText[4][Week]); Memo1->Lines->Add(CCalendar1->CellText[5][Week]); Memo1->Lines->Add(CCalendar1->CellText[6][Week]); } void __fastcall TForm1::FormCreate(TObject *Sender) { Memo1->Clear; AllDaysOfWeek(2006,1, 2); // 印出 2006 年 1 月第 2 周所有日子 } |
y2464372001
一般會員 ![]() ![]() 發表:6 回覆:7 積分:2 註冊:2007-01-23 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |