Display current time and Data time control : Date Time Picker « GUI « VB.Net






Display current time and Data time control

Display current time and Data time control
Imports System.Windows.Forms


Public Class MainClass

    Public Shared Sub Main()
      Application.Run(New Form1)
    End Sub

End Class


Public Class Form1
   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

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

   '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.
   Friend WithEvents lblCurrentTimeIs As System.Windows.Forms.Label
   Friend WithEvents lblCurrentTime As System.Windows.Forms.Label
   Friend WithEvents fraDeliveryTime As System.Windows.Forms.GroupBox
   Friend WithEvents lblDeliveryTime As System.Windows.Forms.Label
   Friend WithEvents lblLasVegasTime As System.Windows.Forms.Label
   Friend WithEvents fraDropOff As System.Windows.Forms.GroupBox
   Friend WithEvents dtpDropOff As System.Windows.Forms.DateTimePicker
   Friend WithEvents tmrClock As System.Windows.Forms.Timer
   Friend WithEvents lblDropOff As System.Windows.Forms.Label
   <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
      Me.components = New System.ComponentModel.Container
      Me.lblCurrentTimeIs = New System.Windows.Forms.Label
      Me.lblCurrentTime = New System.Windows.Forms.Label
      Me.fraDeliveryTime = New System.Windows.Forms.GroupBox
      Me.lblLasVegasTime = New System.Windows.Forms.Label
      Me.lblDeliveryTime = New System.Windows.Forms.Label
      Me.fraDropOff = New System.Windows.Forms.GroupBox
      Me.dtpDropOff = New System.Windows.Forms.DateTimePicker
      Me.lblDropOff = New System.Windows.Forms.Label
      Me.tmrClock = New System.Windows.Forms.Timer(Me.components)
      Me.fraDeliveryTime.SuspendLayout()
      Me.fraDropOff.SuspendLayout()
      Me.SuspendLayout()
      '
      'lblCurrentTimeIs
      '
      Me.lblCurrentTimeIs.Location = New System.Drawing.Point(160, 16)
      Me.lblCurrentTimeIs.Name = "lblCurrentTimeIs"
      Me.lblCurrentTimeIs.TabIndex = 0
      Me.lblCurrentTimeIs.Text = "Current time is:"
      Me.lblCurrentTimeIs.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
      '
      'lblCurrentTime
      '
      Me.lblCurrentTime.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
      Me.lblCurrentTime.Location = New System.Drawing.Point(248, 16)
      Me.lblCurrentTime.Name = "lblCurrentTime"
      Me.lblCurrentTime.Size = New System.Drawing.Size(96, 23)
      Me.lblCurrentTime.TabIndex = 1
      Me.lblCurrentTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
      '
      'fraDeliveryTime
      '
      Me.fraDeliveryTime.Controls.Add(Me.lblLasVegasTime)
      Me.fraDeliveryTime.Controls.Add(Me.lblDeliveryTime)
      Me.fraDeliveryTime.Location = New System.Drawing.Point(16, 136)
      Me.fraDeliveryTime.Name = "fraDeliveryTime"
      Me.fraDeliveryTime.Size = New System.Drawing.Size(328, 73)
      Me.fraDeliveryTime.TabIndex = 2
      Me.fraDeliveryTime.TabStop = False
      Me.fraDeliveryTime.Text = "Get Time Date Pick Value"
      '
      'lblLasVegasTime
      '
      Me.lblLasVegasTime.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
      Me.lblLasVegasTime.Location = New System.Drawing.Point(96, 32)
      Me.lblLasVegasTime.Name = "lblLasVegasTime"
      Me.lblLasVegasTime.Size = New System.Drawing.Size(224, 24)
      Me.lblLasVegasTime.TabIndex = 1
      Me.lblLasVegasTime.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
      '
      'lblDeliveryTime
      '
      Me.lblDeliveryTime.Location = New System.Drawing.Point(13, 32)
      Me.lblDeliveryTime.Name = "lblDeliveryTime"
      Me.lblDeliveryTime.Size = New System.Drawing.Size(80, 23)
      Me.lblDeliveryTime.TabIndex = 0
      Me.lblDeliveryTime.Text = "Delivery time:"
      Me.lblDeliveryTime.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
      '
      'fraDropOff
      '
      Me.fraDropOff.Controls.Add(Me.dtpDropOff)
      Me.fraDropOff.Controls.Add(Me.lblDropOff)
      Me.fraDropOff.Location = New System.Drawing.Point(16, 56)
      Me.fraDropOff.Name = "fraDropOff"
      Me.fraDropOff.Size = New System.Drawing.Size(328, 64)
      Me.fraDropOff.TabIndex = 3
      Me.fraDropOff.TabStop = False
      Me.fraDropOff.Text = "Drop Off"
      '
      'dtpDropOff
      '
      Me.dtpDropOff.CustomFormat = "hh:mm tt"
      Me.dtpDropOff.Format = System.Windows.Forms.DateTimePickerFormat.Custom
      Me.dtpDropOff.Location = New System.Drawing.Point(152, 32)
      Me.dtpDropOff.Name = "dtpDropOff"
      Me.dtpDropOff.ShowUpDown = True
      Me.dtpDropOff.Size = New System.Drawing.Size(88, 21)
      Me.dtpDropOff.TabIndex = 1
      '
      'lblDropOff
      '
      Me.lblDropOff.Location = New System.Drawing.Point(40, 32)
      Me.lblDropOff.Name = "lblDropOff"
      Me.lblDropOff.Size = New System.Drawing.Size(104, 21)
      Me.lblDropOff.TabIndex = 0
      Me.lblDropOff.Text = "Enter time:"
      Me.lblDropOff.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
      '
      'tmrClock
      '
      Me.tmrClock.Enabled = True
      Me.tmrClock.Interval = 1000
      '
      'FrmShippingTime
      '
      Me.AutoScaleBaseSize = New System.Drawing.Size(5, 14)
      Me.ClientSize = New System.Drawing.Size(360, 229)
      Me.Controls.Add(Me.fraDropOff)
      Me.Controls.Add(Me.fraDeliveryTime)
      Me.Controls.Add(Me.lblCurrentTime)
      Me.Controls.Add(Me.lblCurrentTimeIs)
      Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.Name = "Time"
      Me.Text = "Time"
      Me.fraDeliveryTime.ResumeLayout(False)
      Me.fraDropOff.ResumeLayout(False)
      Me.ResumeLayout(False)

   End Sub

#End Region

   Private Sub tmrClock_Tick(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles tmrClock.Tick

      lblCurrentTime.Text = String.Format("{0:hh:mm:ss tt}", _
         Date.Now)

   End Sub

   Private Sub FrmShippingTime_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _
      MyBase.Load

      DisplayDeliveryTime()

   End Sub 

   Private Sub dtpDropOff_ValueChanged(ByVal sender As _
      System.Object, ByVal e As System.EventArgs) Handles _
      dtpDropOff.ValueChanged

      DisplayDeliveryTime()

   End Sub 

   Sub DisplayDeliveryTime()

      lblLasVegasTime.Text = dtpDropOff.Value

   End Sub 
End Class 
           
       








Related examples in the same category

1.Date Time Picker Demo
2.Date Time Picker: get selection rangeDate Time Picker: get selection range