Datetimepicker要顯示label時,年月日可以固定為8碼 |
答題得分者是:pceyes
|
od11112001
一般會員 發表:8 回覆:2 積分:2 註冊:2008-08-04 發送簡訊給我 |
我們在測一個程式
|
careychen
尊榮會員 發表:41 回覆:580 積分:959 註冊:2004-03-03 發送簡訊給我 |
要顯示成妳的時間格式,可以用 formatdatetime('yyyymmdd', now)
這個... 有點要碎碎念一下,妳的上一篇的內容其實可以解決妳現在 PO 的問題,但這篇只是換個方法再問一次 而且妳這篇的類別應該是【問題】,不是【討論】,請修改一下哦!! ===================引 用 od11112001 文 章=================== 我們在測一個程式
|
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
Unit1.pas
[code delphi] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls; type TForm1 = class(TForm) Label2: TLabel; Label3: TLabel; RadioGroup1: TRadioGroup; GroupBox1: TGroupBox; MonthCalendar1: TMonthCalendar; Panel1: TPanel; Label1: TLabel; procedure MonthCalendar1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure RadioGroup1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Date8 : string; APM : string; implementation {$R *.dfm} procedure TForm1.MonthCalendar1Click(Sender: TObject); BEGIN Date8 := formatdatetime('YYYYMMDD',MonthCalendar1.Date); end; procedure TForm1.FormCreate(Sender: TObject); begin Date8 := formatdatetime('YYYYMMDD',Now); // 顯示今天的日期 APM := ''; RadioGroup1.ItemIndex := -1; end; procedure TForm1.RadioGroup1Click(Sender: TObject); begin case RadioGroup1.ItemIndex of 0: APM := 'a'; 1: APM := 'b'; 2: APM := 'c'; end; // 日期 加上 時間 if (Date8 <> '')and(APM <> '') then begin label1.Caption := Date8 APM; end; end; end. [/code] Unit1.dfm [code delphi] object Form1: TForm1 Left = 192 Top = 114 Width = 696 Height = 480 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object Label2: TLabel Left = 16 Top = 16 Width = 34 Height = 48 Caption = '1.' Font.Charset = ANSI_CHARSET Font.Color = clMaroon Font.Height = -48 Font.Name = '新細明體' Font.Style = [] ParentFont = False end object Label3: TLabel Left = 408 Top = 16 Width = 34 Height = 48 Caption = '2.' Font.Charset = ANSI_CHARSET Font.Color = clMaroon Font.Height = -48 Font.Name = '新細明體' Font.Style = [] ParentFont = False end object RadioGroup1: TRadioGroup Left = 472 Top = 72 Width = 153 Height = 273 Caption = '請選擇時段' Font.Charset = CHINESEBIG5_CHARSET Font.Color = clWindowText Font.Height = -21 Font.Name = '新細明體' Font.Style = [] Items.Strings = ( '早' '午' '晚') ParentFont = False TabOrder = 0 OnClick = RadioGroup1Click end object GroupBox1: TGroupBox Left = 8 Top = 56 Width = 439 Height = 291 Caption = '請選擇日期' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -21 Font.Name = 'MS Sans Serif' Font.Style = [] ParentFont = False TabOrder = 1 object MonthCalendar1: TMonthCalendar Left = 2 Top = 26 Width = 435 Height = 263 Align = alClient Date = 39727.659991319440000000 TabOrder = 0 OnClick = MonthCalendar1Click end end object Panel1: TPanel Left = 0 Top = 349 Width = 688 Height = 97 Align = alBottom Caption = 'Panel1' TabOrder = 2 object Label1: TLabel Left = 1 Top = 1 Width = 686 Height = 95 Align = alClient Alignment = taCenter Caption = '顯示區' Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -96 Font.Name = '新細明體' Font.Style = [fsBold] ParentFont = False end end end [/code]
------
努力會更接近成功 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |