全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:3026
推到 Plurk!
推到 Facebook!

取得calendar物件星期

尚未結案
a174709
一般會員


發表:5
回覆:3
積分:1
註冊:2005-08-07

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-08-09 13:37:07 IP:61.221.xxx.xxx 未訂閱
各位大大,我是否可以由calendar物件傳回某一天日期為星期幾?或是由datetime類別得知呢?好像有一個enum為dayofweek,可是小弟不太會用,用法會不會和dayofyear一樣呢?試了好久就dayofweek試不出來,請各位大大指教,謝謝..
y2464372001
一般會員


發表:6
回覆:7
積分:2
註冊:2007-01-23

發送簡訊給我
#2 引用回覆 回覆 發表時間:2007-07-03 10:18:02 IP:140.128.xxx.xxx 訂閱
procedure TForm1.DaysOfWeek(Year: Integer; Month: Integer; Week: Integer);
begin
Calendar1.Year := Year;
Calendar1.Month := Month;
ListBox1.Items.Add(Calendar1.CellText[week,1]);
ListBox1.Items.Add(Calendar1.CellText[week,2]);
ListBox1.Items.Add(Calendar1.CellText[week,3]);
ListBox1.Items.Add(Calendar1.CellText[week,4]);
ListBox1.Items.Add(Calendar1.CellText[week,5]);
ListBox1.Items.Add(Calendar1.CellText[week,6]);
end;


procedure TForm1.Button2Click(Sender: TObject);
var y,w,m: Integer;
dt : TDate;
s :string;
begin
dt := Calendar1.CalendarDate;
y := StrToInt(Formatdatetime('yyyy',dt));
m := StrToInt(Formatdatetime('mm',dt));
s := Label9.Caption;
if s = '星期日' then ListBox1.Items.Add(Calendar1.CellText[0,1]);
if s = '星期一' then ListBox1.Items.Add(Calendar1.CellText[0,2]);
if s = '星期二' then ListBox1.Items.Add(Calendar1.CellText[0,3]);
if s = '星期三' then ListBox1.Items.Add(Calendar1.CellText[0,4]);
if s = '星期四' then ListBox1.Items.Add(Calendar1.CellText[0,5]);
if s = '星期五' then ListBox1.Items.Add(Calendar1.CellText[0,6]);
if s = '星期六' then ListBox1.Items.Add(Calendar1.CellText[0,7]);
w :=ListBox1.Count;
ListBox1.Clear;
DaysOfWeek(y,m,w); // 取出某年某月的某星期所有的天數
end;
fPhoenix
一般會員


發表:0
回覆:20
積分:19
註冊:2005-08-11

發送簡訊給我
#3 引用回覆 回覆 發表時間:2007-09-17 18:09:00 IP:220.229.xxx.xxx 訂閱

[code c#]
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(DateTime.Now.DayOfWeek);
}
}
}

[/code]
系統時間:2024-04-28 22:04:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!