CALENDAR.vb

 Public Class frmCALENDAR
    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 MonthCalendar1 As System.Windows.Forms.MonthCalendar
    Friend WithEvents cboday As System.Windows.Forms.ComboBox
    Friend WithEvents cboMonth As System.Windows.Forms.ComboBox
    Friend WithEvents cboYear As System.Windows.Forms.ComboBox
    Friend WithEvents Label13 As System.Windows.Forms.Label
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    Friend WithEvents lblCaption As System.Windows.Forms.Label
    Friend WithEvents Label14 As System.Windows.Forms.Label
    Public WithEvents btnSelectDate As System.Windows.Forms.Button
    Public WithEvents btnNoDate As System.Windows.Forms.Button
    Public WithEvents Cancel As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmCALENDAR))
        Me.MonthCalendar1 = New System.Windows.Forms.MonthCalendar()
        Me.cboday = New System.Windows.Forms.ComboBox()
        Me.cboMonth = New System.Windows.Forms.ComboBox()
        Me.cboYear = New System.Windows.Forms.ComboBox()
        Me.btnSelectDate = New System.Windows.Forms.Button()
        Me.btnNoDate = New System.Windows.Forms.Button()
        Me.Label13 = New System.Windows.Forms.Label()
        Me.PictureBox1 = New System.Windows.Forms.PictureBox()
        Me.lblCaption = New System.Windows.Forms.Label()
        Me.Label14 = New System.Windows.Forms.Label()
        Me.Cancel = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'MonthCalendar1
        '
        Me.MonthCalendar1.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MonthCalendar1.Location = New System.Drawing.Point(14, 94)
        Me.MonthCalendar1.MaxSelectionCount = 1
        Me.MonthCalendar1.Name = "MonthCalendar1"
        Me.MonthCalendar1.ShowWeekNumbers = True
        Me.MonthCalendar1.TabIndex = 11
        '
        'cboday
        '
        Me.cboday.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cboday.Items.AddRange(New Object() {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"})
        Me.cboday.Location = New System.Drawing.Point(101, 67)
        Me.cboday.Name = "cboday"
        Me.cboday.Size = New System.Drawing.Size(46, 21)
        Me.cboday.TabIndex = 10
        '
        'cboMonth
        '
        Me.cboMonth.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cboMonth.Items.AddRange(New Object() {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"})
        Me.cboMonth.Location = New System.Drawing.Point(14, 67)
        Me.cboMonth.Name = "cboMonth"
        Me.cboMonth.Size = New System.Drawing.Size(88, 21)
        Me.cboMonth.TabIndex = 9
        '
        'cboYear
        '
        Me.cboYear.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cboYear.Location = New System.Drawing.Point(146, 67)
        Me.cboYear.Name = "cboYear"
        Me.cboYear.Size = New System.Drawing.Size(63, 21)
        Me.cboYear.TabIndex = 8
        '
        'btnSelectDate
        '
        Me.btnSelectDate.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnSelectDate.Location = New System.Drawing.Point(79, 260)
        Me.btnSelectDate.Name = "btnSelectDate"
        Me.btnSelectDate.Size = New System.Drawing.Size(71, 21)
        Me.btnSelectDate.TabIndex = 28
        Me.btnSelectDate.Tag = "_saveclose"
        Me.btnSelectDate.Text = "Select Date"
        '
        'btnNoDate
        '
        Me.btnNoDate.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.btnNoDate.Location = New System.Drawing.Point(6, 260)
        Me.btnNoDate.Name = "btnNoDate"
        Me.btnNoDate.Size = New System.Drawing.Size(71, 21)
        Me.btnNoDate.TabIndex = 27
        Me.btnNoDate.Tag = "_savenew"
        Me.btnNoDate.Text = "No Date"
        '
        'Label13
        '
        Me.Label13.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.Label13.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label13.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label13.Location = New System.Drawing.Point(0, 56)
        Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(276, 6)
        Me.Label13.TabIndex = 62
        '
        'PictureBox1
        '
        Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Bitmap)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(58, 56)
        Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
        Me.PictureBox1.TabIndex = 64
        Me.PictureBox1.TabStop = False
        '
        'lblCaption
        '
        Me.lblCaption.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.lblCaption.Font = New System.Drawing.Font("Trebuchet MS", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.lblCaption.ForeColor = System.Drawing.SystemColors.ActiveCaption
        Me.lblCaption.Location = New System.Drawing.Point(62, 12)
        Me.lblCaption.Name = "lblCaption"
        Me.lblCaption.Size = New System.Drawing.Size(198, 22)
        Me.lblCaption.TabIndex = 63
        Me.lblCaption.Text = "Calendar"
        Me.lblCaption.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
        '
        'Label14
        '
        Me.Label14.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label14.Font = New System.Drawing.Font("Haettenschweiler", 20.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label14.ForeColor = System.Drawing.SystemColors.ActiveCaption
        Me.Label14.Location = New System.Drawing.Point(32, 0)
        Me.Label14.Name = "Label14"
        Me.Label14.Size = New System.Drawing.Size(244, 56)
        Me.Label14.TabIndex = 61
        '
        'Cancel
        '
        Me.Cancel.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Cancel.Location = New System.Drawing.Point(152, 260)
        Me.Cancel.Name = "Cancel"
        Me.Cancel.Size = New System.Drawing.Size(71, 21)
        Me.Cancel.TabIndex = 28
        Me.Cancel.Tag = "_cancel"
        Me.Cancel.Text = "Cancel"
        '
        'frmCALENDAR
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(228, 291)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label13, Me.PictureBox1, Me.lblCaption, Me.Label14, Me.btnSelectDate, Me.btnNoDate, Me.MonthCalendar1, Me.cboday, Me.cboMonth, Me.cboYear, Me.Cancel})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmCALENDAR"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "CALENDAR"
        Me.ResumeLayout(False)

    End Sub

#End Region


    Private _DateValue As Date
    Friend Property DateValue() As Date
        Get
            Return _DateValue
        End Get
        Set(ByVal Value As Date)
            _DateValue = Value
        End Set
    End Property



    Private Sub LoadYears()
        Dim ctr As Integer
        Dim start_year As Integer = 1900
        For ctr = 0 To (2078 - 1900) - 1
            With cboYear
                .Items.Add(start_year + ctr)
            End With
        Next
    End Sub

    Private Sub frmCALENDAR_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadYears()
        If Not _DateValue = CDate("#12:00:00 AM#") Then
            MonthCalendar1.SelectionStart = _DateValue
        Else
            MonthCalendar1.SelectionStart = Now
        End If
       
    End Sub


    Private _nodate As String
    Friend ReadOnly Property NoDate() As String
        Get
            Return _nodate
        End Get
    End Property

    Private Sub cboMonth_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
            Handles cboMonth.SelectedIndexChanged, cboday.SelectedIndexChanged, cboYear.SelectedIndexChanged
        If cboMonth.Text.Length <> 0 And cboday.Text.Length <> 0 And cboYear.Text.Length <> 0 Then
            Dim strDate As String = "#" & cboMonth.Text & "/" & cboday.Text & "/" & cboYear.Text & "#"
            If IsDate(strDate) Then
                MonthCalendar1.SelectionStart = CDate(strDate)
            Else
                MessageBox.Show("Not a Valid Date!", "Invalid Date!", MessageBoxButtons.OK, MessageBoxIcon.Error)
                cboday.Text = MonthCalendar1.SelectionStart.Day
                cboMonth.Text = MonthName(MonthCalendar1.SelectionStart.Month)
                cboYear.Text = MonthCalendar1.SelectionStart.Year
            End If
        End If
    End Sub


   
    Private Sub btnSelectDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectDate.Click
        select_date()
    End Sub

    Private Sub select_date()
        _nodate = "withdate"
        _DateValue = MonthCalendar1.SelectionStart
        Me.Close()
    End Sub

    Private Sub btnNoDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNoDate.Click
        _nodate = "nodate"
        Me.Close()
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        _nodate = "cancel"
        Me.Close()
    End Sub

    Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
        cboday.Text = MonthCalendar1.SelectionStart.Day
        cboMonth.Text = MonthName(MonthCalendar1.SelectionStart.Month)
        cboYear.Text = MonthCalendar1.SelectionStart.Year

    End Sub

   




End Class

Project Homepage: