home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form ConvDFInfoS2
- BorderStyle = 3 'Fixed Dialog
- Caption = "Convert 24hr to 12hr"
- ClientHeight = 2550
- ClientLeft = 2460
- ClientTop = 2595
- ClientWidth = 4125
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 1
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 2955
- Left = 2400
- LinkTopic = "Form1"
- ScaleHeight = 2550
- ScaleWidth = 4125
- Top = 2250
- Width = 4245
- Begin VB.CommandButton btnExit
- Cancel = -1 'True
- Caption = "Exit"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 2520
- TabIndex = 6
- Top = 600
- Width = 1335
- End
- Begin VB.TextBox txt12Hour
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 240
- TabIndex = 3
- Text = "txt12Hour"
- Top = 960
- Width = 1935
- End
- Begin VB.TextBox txt24Hour
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 240
- TabIndex = 1
- Text = "txt24Hour"
- Top = 360
- Width = 1935
- End
- Begin VB.CommandButton btnConvert
- Caption = "Convert"
- Default = -1 'True
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 2520
- TabIndex = 0
- Top = 120
- Width = 1335
- End
- Begin VB.Label Label3
- Caption = $"DFINFOS2.frx":0000
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 855
- Left = 240
- TabIndex = 5
- Top = 1440
- Width = 3615
- End
- Begin VB.Label Label2
- Caption = "12 Hour Time:"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 240
- TabIndex = 4
- Top = 720
- Width = 1455
- End
- Begin VB.Label Label1
- Caption = "24 Hour Time:"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 240
- TabIndex = 2
- Top = 120
- Width = 1455
- End
- Attribute VB_Name = "ConvDFInfoS2"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub btnConvert_Click()
- Dim TempStr As String
- '
- ' get the time the user entered and convert it
- '
- TempStr = txt24Hour
- txt12Hour = ConvertDFInfoS2(TempStr)
- End Sub
- Private Sub btnExit_Click()
- '
- ' get out
- '
- End
- End Sub
- ' this function requires the data is valid and in the
- ' format of HH:MM:SS. It does no error checking.
- Private Function ConvertDFInfoS2(TimeString As String) As String
- Dim OutString As String
- Dim TimeHour As Integer
- '
- ' get hour
- '
- TimeHour = Val(Left(TimeString, 2))
- '
- ' format first part of string, make sure 00:00:00
- ' is formatted as 12:00:00
- '
- If (TimeHour Mod 12) = 0 Then
- OutString = "12" & Mid(TimeString, 3)
- Else
- OutString = Format(TimeHour Mod 12, "00") & Mid(TimeString, 3)
- End If
- '
- ' check for AM/PM
- '
- If TimeHour < 12 Then
- OutString = OutString & " AM"
- Else
- OutString = OutString & " PM"
- End If
- '
- ' return new time
- '
- ConvertDFInfoS2 = OutString
- End Function
- Private Sub Form_Load()
- Dim TempStr As String
- '
- ' initialize 24 hour text box
- '
- txt24Hour = Format(Now, "hh:mm:ss")
- '
- ' get 24 hour formatted time and convert it to 12 hour
- '
- TempStr = txt24Hour
- txt12Hour = ConvertDFInfoS2(TempStr)
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- '
- ' make sure we get out
- '
- End
- End Sub
-