Option Explicit On 
Option Strict On

Public Class frmTimes
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents drvFileTimes As Microsoft.VisualBasic.Compatibility.VB6.DriveListBox
    Friend WithEvents dirFileTimes As Microsoft.VisualBasic.Compatibility.VB6.DirListBox
    Friend WithEvents filFileTimes As Microsoft.VisualBasic.Compatibility.VB6.FileListBox
    Friend WithEvents lstTimes As System.Windows.Forms.ListBox
    Friend WithEvents btnTimes As System.Windows.Forms.Button

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.dirFileTimes = New Microsoft.VisualBasic.Compatibility.VB6.DirListBox()
    Me.drvFileTimes = New Microsoft.VisualBasic.Compatibility.VB6.DriveListBox()
    Me.Label1 = New System.Windows.Forms.Label()
    Me.Label2 = New System.Windows.Forms.Label()
    Me.Label3 = New System.Windows.Forms.Label()
    Me.btnTimes = New System.Windows.Forms.Button()
    Me.lstTimes = New System.Windows.Forms.ListBox()
    Me.filFileTimes = New Microsoft.VisualBasic.Compatibility.VB6.FileListBox()
    Me.SuspendLayout()
    '
    'dirFileTimes
    '
    Me.dirFileTimes.IntegralHeight = False
    Me.dirFileTimes.Location = New System.Drawing.Point(8, 64)
    Me.dirFileTimes.Name = "dirFileTimes"
    Me.dirFileTimes.Size = New System.Drawing.Size(160, 128)
    Me.dirFileTimes.TabIndex = 2
    '
    'drvFileTimes
    '
    Me.drvFileTimes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
    Me.drvFileTimes.DropDownWidth = 160
    Me.drvFileTimes.Location = New System.Drawing.Point(8, 24)
    Me.drvFileTimes.Name = "drvFileTimes"
    Me.drvFileTimes.Size = New System.Drawing.Size(160, 21)
    Me.drvFileTimes.TabIndex = 1
    '
    'Label1
    '
    Me.Label1.Location = New System.Drawing.Point(8, 8)
    Me.Label1.Name = "Label1"
    Me.Label1.TabIndex = 0
    Me.Label1.Text = "Drive:"
    '
    'Label2
    '
    Me.Label2.Location = New System.Drawing.Point(8, 48)
    Me.Label2.Name = "Label2"
    Me.Label2.TabIndex = 0
    Me.Label2.Text = "Directory:"
    '
    'Label3
    '
    Me.Label3.Location = New System.Drawing.Point(184, 8)
    Me.Label3.Name = "Label3"
    Me.Label3.TabIndex = 0
    Me.Label3.Text = "Files:"
    '
    'btnTimes
    '
    Me.btnTimes.Location = New System.Drawing.Point(288, 248)
    Me.btnTimes.Name = "btnTimes"
    Me.btnTimes.Size = New System.Drawing.Size(88, 32)
    Me.btnTimes.TabIndex = 5
    Me.btnTimes.Text = "&File Times"
    '
    'lstTimes
    '
    Me.lstTimes.Font = New System.Drawing.Font("Courier New", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.lstTimes.ItemHeight = 16
    Me.lstTimes.Location = New System.Drawing.Point(16, 208)
    Me.lstTimes.Name = "lstTimes"
    Me.lstTimes.Size = New System.Drawing.Size(248, 132)
    Me.lstTimes.TabIndex = 4
    '
    'filFileTimes
    '
    Me.filFileTimes.Font = New System.Drawing.Font("Courier New", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.filFileTimes.ItemHeight = 16
    Me.filFileTimes.Location = New System.Drawing.Point(184, 32)
    Me.filFileTimes.Name = "filFileTimes"
    Me.filFileTimes.Pattern = "*.*"
    Me.filFileTimes.Size = New System.Drawing.Size(192, 164)
    Me.filFileTimes.TabIndex = 3
    '
    'frmTimes
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(396, 353)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnTimes, Me.lstTimes, Me.filFileTimes, Me.dirFileTimes, Me.drvFileTimes, Me.Label3, Me.Label2, Me.Label1})
    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
    Me.Name = "frmTimes"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "File Times Problem"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Private Sub btnTimes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimes.Click
    Dim I As Integer
    Dim FName As String
    Dim HourCount(23) As Integer, Hour As Integer
    Dim TimeInfo As String
    Dim CLoc As Integer, BLoc As Integer
    'Initialize hour counts (24 is for no time info)
    For I = 0 To 24
      HourCount(0) = 0
    Next I
    'Cycle through all files, determining time (if any)
    For I = 0 To filFileTimes.Items.Count - 1
      'Get file name
      If Mid(filFileTimes.Path, Len(filFileTimes.Path), 1) = "\" Then
        FName = filFileTimes.Path + CStr(filFileTimes.Items.Item(I))
      Else
        FName = filFileTimes.Path + "\" + CStr(filFileTimes.Items.Item(I))
      End If
      'Get date/time info and retrieve hour
      Hour = CInt(Format(FileDateTime(FName), "HH"))
      HourCount(Hour) += 1
    Next I
    'Display counts in list box
    lstTimes.Items.Clear()
    lstTimes.Items.Add(Str(filFileTimes.Items.Count) + " Files:")
    For I = 0 To 23
      Select Case I
        Case 0
          TimeInfo = " 12 AM to 1 AM"
        Case 1 To 10
          TimeInfo = Str(I) + " AM to" + Str(I + 1) + " AM"
        Case 11
          TimeInfo = " 11 AM to 12 PM"
        Case 12
          TimeInfo = " 12 PM to 1 PM"
        Case 13 To 22
          TimeInfo = Str(I - 12) + " PM to" + Str(I - 11) + " PM"
        Case 23
          TimeInfo = " 11 PM to 12 AM"
      End Select
      TimeInfo = TimeInfo + "   " + "Count:" + Str(HourCount(I))
      lstTimes.Items.Add(TimeInfo)
    Next I
  End Sub

  Private Sub dirFileTimes_Change(ByVal sender As Object, ByVal e As System.EventArgs) Handles dirFileTimes.Change
    'If directory changes, update file path
    filFileTimes.Path = dirFileTimes.Path
  End Sub

  Private Sub drvFileTimes_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drvFileTimes.SelectedValueChanged
    'If drive changes, update directory
    dirFileTimes.Path = drvFileTimes.Drive
  End Sub
End Class
