2012年4月8日 星期日

DTPicker 顯示民國日期格式(VB6)

Option Explicit
Private Sub DTPicker1_Format(ByVal CallbackField As String, FormattedString As String)
    If CallbackField = "XXXXXXXXX" Then
       FormattedString = Format(DTPicker1.Year - 1911, "###") + "/" + Format(DTPicker1.Month, "00") + "/" + Format(DTPicker1.Day, "00")
       Text1.Text = FormattedString
    End If
End Sub
Private Sub DTPicker1_FormatSize(ByVal CallbackField As String, Size As Integer)
    If CallbackField = "XXXXXXXXX" Then
       Size = Len(CallbackField)
    End If
End Sub
Private Sub Form_Load()
    DTPicker1.Value = Date
    DTPicker1.CustomFormat = "XXXXXXXXX"
    DTPicker1.Format = dtpCustom
End Sub


要加入  mscomctl.ocx和comctl32.ocx了,

沒有留言: