2008年4月23日 星期三

中華民國國歌 (Performed by 復興中學合唱團)





中華民國國歌 (Performed by 復興中學合唱團)


中華民國國旗歌 (Performed by 復興中學合唱團)





中華民國國旗歌 (Performed by 復興中學合唱團)


Portrait of a movie star by Douglas Tang (湯傑堯)[2008-04-23]

Portrait of a movie star by Douglas Tang (湯傑堯)[2008-04-23]

Portrait of a movie star by Douglas Tang (IR90) (with author info) [2008-04-23]

2008年4月22日 星期二

Test_AutoRenameFilesStoredInAFolderWithDateStampPrefixAdded

    Private Sub Test_AutoRenameFilesStoredInAFolderWithDateStampPrefixAdded()
        Dim FP As String
        FP = "E:\WeiJin Tang\Testing Folder"

        Dim myDirectoryInfo As IO.DirectoryInfo
        myDirectoryInfo = New IO.DirectoryInfo(FP)

        Dim myFileInfos() As IO.FileInfo
        myFileInfos = myDirectoryInfo.GetFiles("*.txt")

        Dim FI As IO.FileInfo

        Dim SequenceNumberOfCodeTesting As Integer

        For Each FI In myFileInfos
            Dim FPFN As String
            FPFN = FI.FullName
            Dim FS As IO.FileStream
            FS = New IO.FileStream(FPFN, IO.FileMode.Open, IO.FileAccess.Read)
            'FS = New IO.FileStream(FPFN, IO.FileMode.CreateNew)
            Dim SR As IO.StreamReader
            SR = New IO.StreamReader(FS)

            Dim T As String
            T = SR.ReadToEnd

            Dim RecognizedDateAsOneString As String

            Dim H As WjDateRecognizer_Dot_Y2008M04D03
            H = New WjDateRecognizer_Dot_Y2008M04D03(T)
            RecognizedDateAsOneString = H.GetRecognizedDateAsOneString()

            SR.Close()
            FS.Close()

            Dim FPFNWithDateStamp As String

            SequenceNumberOfCodeTesting += 1

            Dim PathToOutputFolder As String
            PathToOutputFolder = FI.DirectoryName & IO.Path.DirectorySeparatorChar & "Files with DateStamp"
            IO.Directory.CreateDirectory(PathToOutputFolder)

            FPFNWithDateStamp = IO.Path.Combine(PathToOutputFolder, "[" & RecognizedDateAsOneString & "] " & Now.Ticks & " " & FI.Name)

            IO.File.Copy(FPFN, FPFNWithDateStamp)

        Next

    End Sub
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -

miTest_WjStudentIDSelectorY2008M03D11_Click [2008-04-22-PM-09-15-27]

    Private Sub miTest_WjStudentIDSelectorY2008M03D11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miTest_WjStudentIDSelectorY2008M03D11.Click
        'Dim O As WjStudentIDSelectorY2008M03D11
        'O = New WjStudentIDSelectorY2008M03D11(50)

        'Dim StudentIdNumber As String
        'StudentIdNumber = O.SelectAStudentIdNumber

        'Me.Do_PasteStringToTopOfRichTextBox(StudentIdNumber)
        'Me.StatusBar1.Text = StudentIdNumber

        Dim 班號挑選器 As 學生之班號的挑選器Y2008M03D11
        Dim 學生的班號 As String
        班號挑選器 = New 學生之班號的挑選器Y2008M03D11(50)

        學生的班號 = 班號挑選器.挑選一個學生的號碼
        Me.Do_PasteStringToTopOfRichTextBox(學生的班號)
        Me.StatusBar1.Text = "學生的班號 = " & 學生的班號

    End Sub

學生之班號的挑選器Y2008M03D11 [2008-03-11-PM-09-06-44]

' -   -   -   -   -   -   -   -   -   -   -   -   -
' -   -   -   -   -   -   -   -   -   -   -   -   -
'     Object Oriented Programming 2008, Class 01, Serving TSINT_2010級_夜四技_忠班
' -   -   -   -   -   -   -   -   -   -   -   -   -
' -   -   -   -   -   -   -   -   -   -   -   -   -
'     Code Name of this module:
'     OOP2008C01.學生之班號的挑選器
'
' -   -   -   -   -   -   -   -   -   -   -   -   -
' -   -   -   -   -   -  
'     OOP2008C01.學生之班號的挑選器Y2008M03D11 [2008-03-11-PM-09-06-44]
'     Version: 1.00.02
'     Last Updated: (2008 03 11 PM 09 04 09)
' -   -   -   -   -   -  
'     OOP2008C01.學生之班號的挑選器Y2008M03D11 [2008-03-04-PM-08-58-59]
'     Version: 1.00.01
'     Last Updated: (2008 03 11 PM 09 03 15)
' -   -   -   -   -   -   -   -   -   -   -   -   -
' -   -   -   -   -   -   -   -   -   -   -   -   -

Public Class 學生之班號的挑選器Y2008M03D11

    Private m_MaxStudentIdNumber As Integer
    Private m_MinStudentIdNumber As Integer = 1
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Public Sub New(ByVal MaxStudentIdNumber As Integer)
        ' ok

        Me.m_MaxStudentIdNumber = MaxStudentIdNumber

    End Sub
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Public Function 挑選一個學生的號碼() As Integer
        ' ok
        Dim myRandom As System.Random

        myRandom = New System.Random

        Dim myRandomNumber As Integer
        myRandomNumber = myRandom.Next

        Return (myRandomNumber Mod Me.m_MaxStudentIdNumber) + 1

    End Function
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
End Class ' 學生之班號的挑選器Y2008M03D11

OOP2008C01.WjStudentIDSelectorY2008M03D11 [2008-03-11-PM-09-06-44]

' -   -   -   -   -   -   -   -   -   -   -   -   -
' -   -   -   -   -   -   -   -   -   -   -   -   -
'     Object Oriented Programming 2008, Class 01, Serving TSINT_2010級_夜四技_忠班
' -   -   -   -   -   -   -   -   -   -   -   -   -
' -   -   -   -   -   -   -   -   -   -   -   -   -
'     Code Name of this module:
'     OOP2008C01.WjStudentIDSelector
'
' -   -   -   -   -   -   -   -   -   -   -   -   -
' -   -   -   -   -   -  
'     OOP2008C01.WjStudentIDSelectorY2008M03D11 [2008-03-11-PM-09-06-44]
'     Version: 1.00.02
'     Last Updated: (2008 03 11 PM 09 04 09)
' -   -   -   -   -   -  
'     OOP2008C01.WjStudentIDSelectorY2008M03D11 [2008-03-04-PM-08-58-59]
'     Version: 1.00.01
'     Last Updated: (2008 03 11 PM 09 03 15)
' -   -   -   -   -   -   -   -   -   -   -   -   -
' -   -   -   -   -   -   -   -   -   -   -   -   -

Public Class WjStudentIDSelectorY2008M03D11

    Private m_MaxStudentIdNumber As Integer
    Private m_MinStudentIdNumber As Integer = 1
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Public Sub New(ByVal MaxStudentIdNumber As Integer)
        ' ok

        Me.m_MaxStudentIdNumber = MaxStudentIdNumber

    End Sub
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Public Function SelectAStudentIdNumber() As Integer
        ' ok
        Dim myRandom As System.Random

        myRandom = New System.Random

        Dim myRandomNumber As Integer
        myRandomNumber = myRandom.Next

        Return (myRandomNumber Mod Me.m_MaxStudentIdNumber) + 1

    End Function
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
End Class ' WjStudentIDSelectorY2008M03D11

2008年4月19日 星期六

要立志做一個好人,而不只是一個有錢的人! (Be a Good Person Instead of Just a Rich Person!)

要立志做一個好人,而不只是一個有錢的人! (Be a Good Person Instead of Just a Rich Person!)

要立志做一個好人,而不只是一個有錢的人! by WeiJin Tang (湯偉晉)

要立志做一個好人,而不只是一個有錢的人! (Be a Good Person Instead of Just a Rich Person!)

2004/11/1

「要立志做大事,不要立志做大官。」

中華民國的國父 孫中山 先生

要立志做一個好人,而不只是一個有錢的人!
Be a Good Person Instead of Just a Rich Person!

「要立志做一個好人,而不只是一個有錢的人;因為儘管一般的人所看重的,也許會是金錢,但神所看重的卻不是錢,也不是你在世人的眼中,所被看見的外表或被看見做了些什麼樣的事情。神所看重的是,在你的心底,你的內心深處,你是一個怎樣的人。事實上,神仙是不必使用錢的,錢乃是人在使用的;而你是人還是神仙呢?

我要說的是,千萬不要忘了,人乃是從神仙而下凡做人的,要看重自己,不要做慾望與金錢的奴隸,而喪失了自己的人格,和與生俱來的神格;而且時間也終將會證明,那必然是得不償失的。」

湯偉晉 (WeiJin Tang) 寫給他的兒子 湯傑堯 (Douglas Tang)
初稿,寫於 2004/11/1
001版,寫於 2004/11/1
002版,新增及修飾於 2006/10/15
003版,新增 English title 2006/12/25

Posted by WeiJin Tang (
湯偉晉) at 1:36 PM

2008年4月18日 星期五

電腦(軟體人類)會做的事情,人類最好不要和它競爭,因為人類注定失敗。

2008-04-19


電腦(軟體人類)會做的事情,人類最好不要和它競爭,因為人類注定失敗


湯偉晉 親手原創性地寫作於 1998

多層次及多方位的思維模式


要懂得善加使用軟體;電腦(軟體人類)。

資料庫管理系統,期中測驗的題目 [2008-04-19]

資料庫2008S [2008-04-19]

2009
_進二技_篤班

資料庫管理系統,期中測驗的題目

2008-04-19
在一個全面電腦化的公司中,企業重要的資料,一般都放在那裡? 為什麼?

在關聯式資料庫中,主索引鍵的功能為何? 它具有什麼樣的特性?

在關聯式資料庫中,外部索引鍵的功能為何? 它具有什麼樣的特性?

在設計一個關聯式資料庫時,我們要如何決定,該把哪些資料,放進資料庫中,儲存起來?

在關聯式資料庫的某一個資料表中,所存放的各筆記錄之間,彼此具有什麼樣的關係?

何謂 「多層次及多方位的思維模式」? 請以你在學習關聯式資料庫之課程中的經驗,略為述說一下,在設計一個關聯式資料庫時,有哪些不同層次的問題,需要加以考慮?


資料分析
關聯式資料庫
結構化的資料
多層次及多方位的思維模式
了解為什麼必須按照這樣的規定去做
關鍵字
慎思明辨 獨立思考


2008年4月15日 星期二

傳回這個等差數列的總和 [2008-04-15]

    Public Function 傳回這個等差數列的總和(ByVal 開始的數值 As Integer, ByVal 最後的數值 As Integer, ByVal 相鄰兩個數值的差 As Integer) As Integer
        ' (本段程式之目的) Purpose:
        '     Explanation
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 80% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 80% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2008 04 15 PM 08 57 51)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     OK
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Dim 數列的總和 As Integer

        For i As Integer = 開始的數值 To 最後的數值 Step 相鄰兩個數值的差
            數列的總和 = 數列的總和 + i
        Next

        Return 數列的總和

    End Function ' 傳回這個等差數列的總和
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -

2008年4月3日 星期四

WJAtTSINT2008.Tools_for_WJAtTSINT2008 ; Version: 1.00.01 ; Last Updated: (2008 04 03 PM 07 10 18)

'     (友善的模組名稱) Friendly name of this module:
'           [WJAtTSINT2008].[Tools for WJAtTSINT2008]
'
'     (程式用模組名稱) Code name of this module:
'           WJAtTSINT2008.Tools_for_WJAtTSINT2008
'
'     Version: 1.00.01
'     Last Updated: (2008 04 03 PM 07 10 18)

Module Tools_for_WJAtTSINT2008
    Public Function GetStringInClipboard() As String
        ' (本段程式之目的) Purpose:
        '     Get the text content currently stored in system's clipboard.
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (重要等級) Importance rating:  85%
        ' (再利用的可能性) Chances of reuse:  90%
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 80% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 80% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2005 09 01 PM 01 50 25)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     OK
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Dim myDataObject As System.Windows.Forms.IDataObject
        Dim T As String
        myDataObject = System.Windows.Forms.Clipboard.GetDataObject()

        ' Try to return Unicode Text first, if failed, then try to return ANSI Text
        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.UnicodeText) Then
            T = myDataObject.GetData(System.Windows.Forms.DataFormats.UnicodeText)
        Else
            If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Text) Then
                T = myDataObject.GetData(System.Windows.Forms.DataFormats.Text)
            Else
                T = String.Empty
            End If
        End If

        Return T

        ' Begin: Reusable code block (2005 09 01 PM 10 26 20)
        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Text) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Text]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Text]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.UnicodeText) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.UnicodeText]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.UnicodeText]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.WaveAudio) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.WaveAudio]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.WaveAudio]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Html) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Html]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Html]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Rtf) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Rtf]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Rtf]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Bitmap]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Bitmap]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.PenData) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.PenData]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.PenData]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.StringFormat) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.StringFormat]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.StringFormat]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Serializable) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Serializable]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Serializable]")
        End If

        If myDataObject.GetDataPresent(System.Windows.Forms.DataFormats.Riff) Then
            MsgBox("Clipboard content is compatible with data type [System.Windows.Forms.DataFormats.Riff]")
        Else
            MsgBox("Clipboard content is    NOT      compatible with data type  [System.Windows.Forms.DataFormats.Riff]")
        End If
        ' End:    Reusable code block (2005 09 01 PM 10 26 20)

    End Function ' GetStringInClipboard
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Public Sub PasteStringToClipboard(ByVal AnyString As String)
        ' (本段程式之目的) Purpose:
        '     Paste string to Clipboard.
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (重要等級) Importance rating:  80%
        ' (再利用的可能性) Chances of reuse:  90%
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 80% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 80% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2004 12 06 PM 03 17 30)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     ok
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Clipboard.SetDataObject(AnyString, True)

    End Sub ' PasteStringToClipboard
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Public Function GetStandardDateStamp_used_on_PDA() As String
        ' (本段程式之目的) Purpose:
        '     Return a time stamp like
        '               "2008-04-03"
        '     which is the default date stamp used on a PDA.
        '
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 80% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 80% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2008 04 03 PM 04 42 35)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     OK
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Dim ThisMoment As Date
        ThisMoment = Now.Today

        Dim Y As String
        Dim M As String
        Dim D As String
        Y = ThisMoment.Year.ToString.PadLeft(4, "0"c)
        M = ThisMoment.Month.ToString.PadLeft(2, "0"c)
        D = ThisMoment.Day.ToString.PadLeft(2, "0"c)

        Return Y & "-" & M & "-" & D

    End Function ' GetStandardDateStamp_used_on_PDA
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -

End Module ' Tools_for_WJAtTSINT2008

 

Test_WjDateRecognizerY2008M04D03 ; [2008-04-03]

    Private Sub Test_WjDateRecognizerY2008M04D03()
        ' (本段程式之目的) Purpose:
        '     Explanation
        ' (本段程式是否已經在被使用中) In use: Yes No
        ' (重要等級) Importance rating:  60%
        ' (再利用的可能性) Chances of reuse:  40%
        ' (程式撰寫的進度) Developing: Ongoing (80%)
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 0% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 0% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2008 04 01 PM 08 12 00)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     DescriptionOfThisRevision
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Dim AnyText As String
        AnyText = "This2008/04/01Happy"
        AnyText = "2008/04/01Happy"
        AnyText = "aaa2008/04/0"
        AnyText = "aaa2008/04/02"
        AnyText = "aaa2008/03/29"
        'AnyText = "08/04/01Happy"

        AnyText = GetStringInClipboard()

        Dim H As WjDateRecognizer_Slash_Y2008M04D03
        H = New WjDateRecognizer_Slash_Y2008M04D03(AnyText)

        ' Test OK
        'Dim H As WjDateRecognizer_Hyphen_Y2008M04D03
        'H = New WjDateRecognizer_Hyphen_Y2008M04D03(AnyText)

        Dim myRecognizedDateAsOneString As String
        myRecognizedDateAsOneString = H.GetRecognizedDateAsOneString

        Me.Do_PasteStringToTopOfRichTextBox(myRecognizedDateAsOneString)

        PasteStringToClipboard(myRecognizedDateAsOneString)

    End Sub ' Test_WjDateRecognizerY2008M04D03
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -

WjDateRecognizer_Slash_Y2008M04D03 ; [2008-04-03]

' -   -   -   -   -   -   -   -   -   -   -   -   -
' -   -   -   -   -   -   -   -   -   -   -   -   -
'     (著作權聲明) Copyright Statement:
'           Copyright 2000-2008, SoftHuman Corporation. All rights reserved.
'           善解科技股份有限公司
'           著作權 2000-2008。版權所有,保留一切權利。
'
'     (本段程式之目的) Purpose:
'           Object of this class can help you to automatically recognize a string with
'           date info, like "2008/04/01", embedded in it, and help to convert it to a date stamp like "2008-04-01".
'
'     (友善的模組名稱) Friendly name of this module:
'           [WJAtTSINT2008].[Wj Date Recognizer _Slash_Y2008M04D03]
'
'     (程式用模組名稱) Code name of this module:
'           WJAtTSINT2008.WjDateRecognizer_Slash_Y2008M04D03
'
'     (本段程式是否已經在被使用中) In use: Yes
'     (程式撰寫的進度) Developing: 100% (Mandatory)
'     (程式堪用的程度) Workable: 80% (Threshold at 80%)
'     (程式的測試程度) Code tested: 80% (max 99%)
'
'     WjDateRecognizer_Slash_Y2008M04D03 [2008-04-03-AM-08-09-14]
'
'     Version: 1.00.03
'     Last Updated: (2008 04 03 PM 06 29 42)
'     Version: 1.00.02
'     Last Updated: (2008 04 03 AM 08 08 27)
'     Version: 1.00.01
'     Last Updated: (2008 04 01 PM 10 02 29)
'
' -   -   -   -   -   -   -   -   -   -   -   -   -
' -   -   -   -   -   -   -   -   -   -   -   -   -

Public Class WjDateRecognizer_Slash_Y2008M04D03

    Private Class DateInfoVerifier_Slash_Y2008M04D03
        Private Const TextWithTheOnlyValidDecimalChars As String = "0123456789"
        Private Const LengthOfValidDateInfo As Integer = 10
        Private Const PositionOfFirstSlashChar As Integer = 4
        Private Const PositionOfSecondSlashChar As Integer = 7
        Private Const CharacteristicString_Slash As String = "/"

        Private m_IsAValidDateInfo As Boolean = False
        Private m_TextWithPossibleDateInfo As String
        Private m_DateParsedFromGivenDateInfo As Date = Nothing

        Public Sub New(ByVal TextWithPossibleDateInfo As String)
            ' (本段程式之目的) Purpose:
            '     Explanation
            ' (本段程式是否已經在被使用中) In use: Yes
            ' (程式撰寫的進度) Developing: 100% (Mandatory)
            ' (程式堪用的程度) Workable: 80% (Threshold at 80%)
            ' (程式的測試程度) Code tested: 70% (max 99%)
            ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            ' (修改程式的日期) Revision Date: (2008 04 03 AM 07 09 25)
            ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
            '     OK
            ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

            Dim T As String
            T = TextWithPossibleDateInfo

            ' If it is not a valid Date Info string
            If T.Length <> Me.LengthOfValidDateInfo Then
                Me.m_IsAValidDateInfo = False
                Me.m_DateParsedFromGivenDateInfo = Now.Today
                Exit Sub
            End If

            Dim myPositionOfFirstSlashChar As Integer
            Dim myPositionOfSecondSlashChar As Integer

            myPositionOfFirstSlashChar = T.IndexOf(Me.CharacteristicString_Slash)
            If myPositionOfFirstSlashChar <> Me.PositionOfFirstSlashChar Then
                Me.m_IsAValidDateInfo = False
                Me.m_DateParsedFromGivenDateInfo = Now.Today
                Exit Sub
            End If

            myPositionOfSecondSlashChar = T.LastIndexOf(Me.CharacteristicString_Slash)
            If myPositionOfSecondSlashChar <> Me.PositionOfSecondSlashChar Then
                Me.m_IsAValidDateInfo = False
                Me.m_DateParsedFromGivenDateInfo = Now.Today
                Exit Sub
            End If

            ' Text with year's data, text with month's data, and text with day's data; all as string
            Dim TY, TM, TD As String
            ' number with year's data, text with month's data, and text with day's data; all as integer
            Dim Y, M, D As Integer
            TY = T.Substring(0, 4)
            TM = T.Substring(Me.PositionOfFirstSlashChar + 1, 2)
            TD = T.Substring(Me.PositionOfSecondSlashChar + 1, 2)

            ' Begin_[2008_04_03_PM_04_54_48]
            ' Comments by WeiJin Tang (湯偉晉) :
            '   Make sure every character in TY, TM, TD are valid decimal characters, i.e. from 0, 1, ... , 8, 9.
            '  
            Dim T3 As String
            T3 = TY & TM & TD
            Dim C3 As Char

            For i As Integer = 0 To T3.Length - 1
                C3 = T3.Chars(i)

                ' If character C3 is not a valid decimal character
                If Me.TextWithTheOnlyValidDecimalChars.IndexOf(C3) < 0 Then
                    Me.m_IsAValidDateInfo = False
                    Me.m_DateParsedFromGivenDateInfo = Now.Today
                    Exit Sub
                End If
            Next
            '  
            ' End_[2008_04_03_PM_04_54_48]

            Try
                Y = CType(TY, Integer)
                M = CType(TM, Integer)
                D = CType(TD, Integer)
            Catch ex As Exception
                Me.m_IsAValidDateInfo = False
                Me.m_DateParsedFromGivenDateInfo = Now.Today
                Exit Sub
            End Try

            Dim myDate As Date

            ' wjNote:
            '   Use this trick to make sure the generated date object is reasonable.
            Try
                myDate = New Date(Y, M, D)

                Me.m_IsAValidDateInfo = True
                Me.m_DateParsedFromGivenDateInfo = myDate
            Catch ex As Exception
                Me.m_IsAValidDateInfo = False
                Me.m_DateParsedFromGivenDateInfo = Now.Today
                Exit Sub
            End Try
        End Sub

        Public ReadOnly Property IsAValidDateInfo() As Boolean
            ' ok
            Get
                Return Me.m_IsAValidDateInfo
            End Get
        End Property

        Public Function GetParsedDateOrDefaultDate() As Date
            ' OK
            Return Me.m_DateParsedFromGivenDateInfo
        End Function

        Public Function GetParsedDateOrDefaultDateAsOneString() As String
            ' OK

            Dim D As Date
            D = Me.m_DateParsedFromGivenDateInfo

            Dim SB As New System.Text.StringBuilder

            With SB
                .Append(D.Year.ToString.PadLeft(4, "0"c))
                .Append("-")
                .Append(D.Month.ToString.PadLeft(2, "0"c))
                .Append("-")
                .Append(D.Day.ToString.PadLeft(2, "0"c))
            End With

            Return SB.ToString

        End Function

    End Class ' DateInfoVerifier_Slash_Y2008M04D03

    ' Begin_[2008_04_01_PM_09_43_19]
    ' Comments by WeiJin Tang (湯偉晉) :
    '   Constants used by this object
    '  
    Private Const LengthOfValidDateInfo As Integer = 10
    Private Const InitialValue_for_PositionOfFirstSlash As Integer = -1
    Private Const InitialValue_for_PositionOfSecondSlash As Integer = -1
    Private Const InitialValue_for_PositionOfTheFirstOtherSlashChar As Integer = -1
    Private Const MinLength_for_TextWithPossibleDateInfo As Integer = 10
    '  
    ' End_[2008_04_01_PM_09_43_19]

    Private m_TextWithPossibleDateInfo As String

    Private m_RecognizedDate As Date

    Private m_PositionOfFirstSlash As Integer = Me.InitialValue_for_PositionOfFirstSlash ' Initial value
    Private m_PositionOfSecondSlash As Integer = Me.InitialValue_for_PositionOfSecondSlash ' Initial value
    Private m_PositionOfTheFirstOtherSlashChar As Integer = Me.InitialValue_for_PositionOfTheFirstOtherSlashChar ' Initial value

    ' Begin_[2008_04_01_PM_08_33_53]
    ' Comments by WeiJin Tang (湯偉晉) :
    '   Characteristic features of the to-be-recognized date info
    '  
    Private Const DistanceBetweenThe2SlashChars As Integer = 3
    Private Const MinNumberOfCharactersBeforeFirstSlash As Integer = 4
    Private Const MinNumberOfCharactersAfterSecondSlash As Integer = 2
    Private Const CharacteristicString_Slash As String = "/"
    '  
    ' End_[2008_04_01_PM_08_33_53]

    Public Sub New(ByVal AnyText As String)
        ' OK
        Me.m_TextWithPossibleDateInfo = AnyText

        Me.Do_ParseTextForPossibleDateInfo(Me.m_TextWithPossibleDateInfo)

    End Sub

    Private ReadOnly Property TextWithPossibleDateInfo() As String
        ' Ok
        Get
            Return Me.m_TextWithPossibleDateInfo
        End Get
    End Property

    Public Function GetRecognizedDate() As Date
        Return Me.m_RecognizedDate
    End Function

    Public Function GetRecognizedDateAsOneString() As String
        ' (本段程式之目的) Purpose:
        '     Explanation
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (重要等級) Importance rating:  60%
        ' (再利用的可能性) Chances of reuse:  40%
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 80% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 70% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2008 04 03 AM 05 48 58)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     OK
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Dim D As Date
        D = Me.GetRecognizedDate

        Dim SB As New System.Text.StringBuilder

        With SB
            .Append(D.Year.ToString.PadLeft(4, "0"c))
            .Append("-")
            .Append(D.Month.ToString.PadLeft(2, "0"c))
            .Append("-")
            .Append(D.Day.ToString.PadLeft(2, "0"c))
        End With

        ' Return a string like "2008-03-29"
        Return SB.ToString

    End Function ' GetRecognizedDateAsOneString
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -

    Private Sub Do_ParseTextForPossibleDateInfo(ByVal TextWithPossibleDateInfo As String)
        ' (本段程式之目的) Purpose:
        '     Explanation
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (重要等級) Importance rating:  90%
        ' (再利用的可能性) Chances of reuse:  85%
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 80% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 75% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2008 04 01 PM 07 37 56)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     OK
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Dim T As String

        If TextWithPossibleDateInfo.Length >= Me.MinLength_for_TextWithPossibleDateInfo Then
            T = TextWithPossibleDateInfo
        Else
            ' Length of   TextWithPossibleDateInfo   is too short to hold a valid date info
            Me.m_RecognizedDate = Now.Today
            Exit Sub
        End If

        Me.m_PositionOfFirstSlash = T.IndexOf(Me.CharacteristicString_Slash)

        ' if we can't find any "/" char in working string T
        If Me.m_PositionOfFirstSlash < 0 Then
            Me.m_RecognizedDate = Now.Today
            Exit Sub
        End If

        ' Position of first slash char violates the required position constraints
        If Me.m_PositionOfFirstSlash < Me.MinNumberOfCharactersBeforeFirstSlash Then
            Dim myStartPositionOfRemainingTextToParse As Integer
            myStartPositionOfRemainingTextToParse = Me.m_PositionOfFirstSlash + 1

            Dim myRemainingTextToParse As String
            Dim myLengthOfRemainingTextToParse As Integer

            ' if there is no enough room to hold a valid date info string then simply use the default date.
            If myStartPositionOfRemainingTextToParse + Me.MinLength_for_TextWithPossibleDateInfo > TextWithPossibleDateInfo.Length Then
                Me.m_RecognizedDate = Now.Today
                Exit Sub
            Else

                myLengthOfRemainingTextToParse = TextWithPossibleDateInfo.Length - myStartPositionOfRemainingTextToParse

                myRemainingTextToParse = TextWithPossibleDateInfo.Substring(myStartPositionOfRemainingTextToParse, myLengthOfRemainingTextToParse)

            End If

            Me.m_PositionOfFirstSlash = Me.InitialValue_for_PositionOfFirstSlash
            Me.m_PositionOfSecondSlash = Me.InitialValue_for_PositionOfSecondSlash

            Me.Do_ParseTextForPossibleDateInfo(myRemainingTextToParse)
            Exit Sub

        End If ' Me.m_PositionOfFirstSlash < Me.MinNumberOfCharactersBeforeFirstSlash

        Me.m_PositionOfSecondSlash = T.IndexOf(Me.CharacteristicString_Slash, Me.m_PositionOfFirstSlash + 1)

        If Me.m_PositionOfSecondSlash - Me.m_PositionOfFirstSlash = Me.DistanceBetweenThe2SlashChars Then
            ' If T is a string like
            '      "This2008/04/01Happy"   ,   "This2008/??/01Happy"  , or  "This????/??/??Happy"
            '
            ' We might have found a possible Date Info to recognize

            ' Begin_[2008_04_01_PM_09_50_01]
            ' Comments by WeiJin Tang (湯偉晉) :
            '   Check position constraints imposed on the to-be-recognized date info
            '  

            ' Position of first slash char violates the required position constraints
            If Me.m_PositionOfFirstSlash < Me.MinNumberOfCharactersBeforeFirstSlash Then

                Dim myStartPositionOfRemainingTextToParse As Integer
                myStartPositionOfRemainingTextToParse = Me.m_PositionOfFirstSlash + 1

                Dim myRemainingTextToParse As String
                Dim myLengthOfRemainingTextToParse As Integer

                ' if there is no enough room to hold a valid date info string then simply use the default date.
                If myStartPositionOfRemainingTextToParse + Me.MinLength_for_TextWithPossibleDateInfo > TextWithPossibleDateInfo.Length Then
                    Me.m_RecognizedDate = Now.Today
                    Exit Sub
                Else

                    myLengthOfRemainingTextToParse = TextWithPossibleDateInfo.Length - myStartPositionOfRemainingTextToParse

                    myRemainingTextToParse = TextWithPossibleDateInfo.Substring(myStartPositionOfRemainingTextToParse, myLengthOfRemainingTextToParse)

                End If

                Me.m_PositionOfFirstSlash = Me.InitialValue_for_PositionOfFirstSlash
                Me.m_PositionOfSecondSlash = Me.InitialValue_for_PositionOfSecondSlash

                Me.Do_ParseTextForPossibleDateInfo(myRemainingTextToParse)
                Exit Sub

                '' Position of second slash char also violates the required position constraints
                'If Me.m_PositionOfSecondSlash < Me.MinNumberOfCharactersBeforeFirstSlash Then

                'Else

                'End If

            Else
                ' Position of first slash char satisfies the required position constraints
                '
                ' Continue to check whether there are enough characters after the second slash character.
                If Me.m_PositionOfSecondSlash + Me.MinNumberOfCharactersAfterSecondSlash < T.Length Then

                    Dim myTextWithPossibleDateInfo As String
                    myTextWithPossibleDateInfo = T.Substring(Me.m_PositionOfFirstSlash - Me.MinNumberOfCharactersBeforeFirstSlash, Me.LengthOfValidDateInfo)

                    ' we are almost done, if we are lucky
                    'MsgBox("myTextWithPossibleDateInfo = " & myTextWithPossibleDateInfo)

                    Dim H As WjDateRecognizer_Slash_Y2008M04D03.DateInfoVerifier_Slash_Y2008M04D03
                    H = New WjDateRecognizer_Slash_Y2008M04D03.DateInfoVerifier_Slash_Y2008M04D03(myTextWithPossibleDateInfo)

                    If H.IsAValidDateInfo Then
                        'MsgBox("H.GetParsedDateOrDefaultDateAsOneString() = " & H.GetParsedDateOrDefaultDateAsOneString())
                        Me.m_RecognizedDate = H.GetParsedDateOrDefaultDate
                        Exit Sub
                    Else
                        ' Keep working ..., since this is not a valid Date Info string

                        Dim myStartPositionOfRemainingTextToParse As Integer
                        myStartPositionOfRemainingTextToParse = Me.m_PositionOfSecondSlash + 1

                        Dim myRemainingTextToParse As String
                        Dim myLengthOfRemainingTextToParse As Integer

                        ' if there is no enough room to hold a valid date info string then simply use the default date.
                        If myStartPositionOfRemainingTextToParse + Me.MinLength_for_TextWithPossibleDateInfo > TextWithPossibleDateInfo.Length Then
                            Me.m_RecognizedDate = Now.Today
                            Exit Sub
                        Else
                            myLengthOfRemainingTextToParse = TextWithPossibleDateInfo.Length - myStartPositionOfRemainingTextToParse

                            myRemainingTextToParse = TextWithPossibleDateInfo.Substring(myStartPositionOfRemainingTextToParse, myLengthOfRemainingTextToParse)

                        End If

                        Me.m_PositionOfFirstSlash = Me.InitialValue_for_PositionOfFirstSlash
                        Me.m_PositionOfSecondSlash = Me.InitialValue_for_PositionOfSecondSlash

                        Me.Do_ParseTextForPossibleDateInfo(myRemainingTextToParse)
                        Exit Sub
                    End If
                    Exit Sub
                Else
                    ' this string T can't contain a recognizable date info since there's no enough room at the end, i.e. after the 2nd slash char
                    Me.m_RecognizedDate = Now.Today
                    Exit Sub
                End If
            End If
            '  
            ' End_[2008_04_01_PM_09_50_01]
        Else
            ' If T is a string like
            '     "This2008/04ABC/01Happy"
            '
            ' It is not a valid characteristic feature, so we need to update the position of the first slash.
            Me.m_PositionOfFirstSlash = Me.m_PositionOfSecondSlash
            Me.m_PositionOfSecondSlash = Me.InitialValue_for_PositionOfSecondSlash

            Dim myRemainingTextToParse As String
            Dim myStartPositionOfRemainingTextToParse As Integer
            myStartPositionOfRemainingTextToParse = Me.m_PositionOfFirstSlash - Me.MinNumberOfCharactersBeforeFirstSlash ' me.MinNumberOfCharactersBeforeFirstSlash = 4

            Dim myLengthOfRemainingTextToParse As Integer
            myLengthOfRemainingTextToParse = TextWithPossibleDateInfo.Length - myStartPositionOfRemainingTextToParse

            myRemainingTextToParse = TextWithPossibleDateInfo.Substring(myStartPositionOfRemainingTextToParse, myLengthOfRemainingTextToParse)

            Me.Do_ParseTextForPossibleDateInfo(myRemainingTextToParse)
            Exit Sub
        End If

    End Sub ' Do_ParseTextForPossibleDateInfo
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    Private Function Get_PositionOfTheFirstOtherSlashChar() As Integer
        ' (本段程式之目的) Purpose:
        '     Explanation
        ' (本段程式是否已經在被使用中) In use: Yes
        ' (重要等級) Importance rating:  60%
        ' (再利用的可能性) Chances of reuse:  40%
        ' (程式撰寫的進度) Developing: 100% (Mandatory)
        ' (程式堪用的程度) Workable: 0% (Threshold at 80%)
        ' (程式的測試程度) Code tested: 0% (max 99%)
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ' (修改程式的日期) Revision Date: (2008 04 01 PM 09 04 26)
        ' (修改程式的人員) Revised by: WeiJin Tang (湯偉晉)
        '     OK
        ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Return Me.m_PositionOfTheFirstOtherSlashChar

    End Function ' Get_PositionOfTheFirstOtherSlashChar
    ' -   -   -   -   -   -   -   -   -   -   -   -   -
    ' -   -   -   -   -   -   -   -   -   -   -   -   -

End Class ' WjDateRecognizer_Slash_Y2008M04D03