VB.Net/GUI/Date Time Picker
Date Time Picker Demo
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing
Public Class MainClass
Shared Sub Main()
Dim form1 As Form = New Form1
Application.Run(form1)
End Sub
End Class
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _
Partial Public Class Form1
Inherits System.Windows.Forms.Form
"Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
"Required by the Windows Form Designer
Private components As System.ruponentModel.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.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.DateTimePicker2 = New System.Windows.Forms.DateTimePicker
Me.SuspendLayout()
"
"DateTimePicker1
"
Me.DateTimePicker1.Location = New System.Drawing.Point(64, 16)
Me.DateTimePicker1.Name = "DateTimePicker1"
Me.DateTimePicker1.Size = New System.Drawing.Size(200, 20)
Me.DateTimePicker1.TabIndex = 0
"
"Label1
"
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(8, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(51, 13)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Start Date"
"
"Label2
"
Me.Label2.AutoSize = True
Me.Label2.Location = New System.Drawing.Point(8, 48)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(48, 13)
Me.Label2.TabIndex = 3
Me.Label2.Text = "End Date"
"
"DateTimePicker2
"
Me.DateTimePicker2.Location = New System.Drawing.Point(64, 48)
Me.DateTimePicker2.Name = "DateTimePicker2"
Me.DateTimePicker2.Size = New System.Drawing.Size(200, 20)
Me.DateTimePicker2.TabIndex = 2
"
"Form1
"
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.DateTimePicker2)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.DateTimePicker1)
Me.Name = "Form1"
Me.Text = "UseDateTimePicker"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents DateTimePicker2 As System.Windows.Forms.DateTimePicker
End Class
Date Time Picker: get selection range
Imports System.Windows.Forms
Imports System.Drawing
Imports System.IO
Module Module1
Sub Main()
Application.Run(New Form1)
End Sub
End Module
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.ruponentModel.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 MonthCalendar1 As System.Windows.Forms.MonthCalendar
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.MonthCalendar1 = New System.Windows.Forms.MonthCalendar()
Me.Button1 = New System.Windows.Forms.Button()
Me.SuspendLayout()
"
"MonthCalendar1
"
Me.MonthCalendar1.Location = New System.Drawing.Point(56, 24)
Me.MonthCalendar1.Name = "MonthCalendar1"
Me.MonthCalendar1.TabIndex = 0
"
"Button1
"
Me.Button1.Location = New System.Drawing.Point(112, 216)
Me.Button1.Name = "Button1"
Me.Button1.TabIndex = 1
Me.Button1.Text = "Done"
"
"Form1
"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(288, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1, Me.MonthCalendar1})
Me.Name = "Form1"
Me.Text = "MonthlyCalendarDemo"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
MessageBox.Show("You selected: " & MonthCalendar1.SelectionRange.ToString())
End Sub
End Class
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.ruponentModel.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.ruponents = New System.ruponentModel.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.ruponents)
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