___________________________________________________________________

การใช้งาน

 

Private TimeSet As New TimeFlow _
With {.Hr = 0, .Min = 1, .Sec = 30 , .Start = Date.Now}

Private Sub Tick() Handles Timer.Tick
    If ( Timeset Or Date.Now) = True Then
         ' Do someting
    Else
         Label.Text = TimeSet Xor Date.Now
    End If
End Sub
____________________________________________________________________

ตัวโค๊ด

 

Structure TimeFlow
Dim Hr, Min, Sec As Integer
Dim Start As Date

Public Shared Operator Or _
(ByVal t As TimeFlow, ByVal d As Date) As Boolean
    Return If(t.Start.Add(New System.TimeSpan(Hr,Min,Sec)) = d, True, False)
End Operator

Public Shared Operator Xor _
(ByVal t As TimeFlow, ByVal d As Date) As String
    Return (t.Start.Add(New System.TimeSpan(Hr,Min,Sec)) - d).ToString
End Operator

End Structure

____________________________________________________________________

 

Credit inet03.exteen.com 

Comment

Comment:

Tweet

ขอบคุณค้า

#1 By ff (202.28.51.72) on 2010-09-19 12:05