PITime Example

 

This example, during the Form_Load, initializes the form.  When the command buttons are hit, the program extracts the string from the text box, converts it to the expected data type (Date or Double) and assigns it to the appropriate property of a PITime object.  It then converts the time to various formats by displaying the PITime properties.

 

Build the PITime example as follows:

1. Create a new project and add a reference to the PITimeServer library.

2. Add the visual elements as shown in the picture. Make sure the numbered element names (label1, list1, etc.) match those shown.

3. Cut and paste the code below into the project.

 

Private Sub Command1_Click()
On Error GoTo eh
    If Len(Text1.Text) = 0 Then
        MsgBox "Please enter a date as a string to convert."
        Exit Sub
    End If
    Dim pt1 As New PITime
    pt1.LocalDate = Text1.Text
    ShowPITime pt1
Exit Sub
eh:
    MsgBox Err.Description
End Sub

Private Sub Command2_Click()
On Error GoTo eh
    If Len(Text2.Text) = 0 Then
        MsgBox "Please enter seconds since 1970 to convert."
        Exit Sub
    End If
    Dim pt2 As New PITime
    pt2 = CDbl(Text2.Text)
    ShowPITime pt2
Exit Sub
eh:
    MsgBox Err.Description
End Sub

Private Sub Form_Load()
    Text1.Text = ""
    Text2.Text = ""
    ResetDisplay
End Sub
Private Sub ResetDisplay()
    Label5.Caption = ""
    Label6.Caption = ""
    Label7.Caption = ""
    Label8.Caption = ""
End Sub
Private Sub ShowPITime(pt As PITime)
   ResetDisplay
   Label5.Caption = CStr(pt.LocalDate)
   Dim dtdbl As Double
   dtdbl = pt.LocalDate
   Label6.Caption = CStr(dtdbl)
   Label7.Caption = CStr(pt.UTCSeconds)
   Label8.Caption = CStr(pt.UTCFileTime)
End Sub

  
Enabling Operational Intelligence