• We just launched and are currently in beta. Join us as we build and grow the community.

DateTimePicker Control

mediker27

Ad Revenue Innovator
M Rep
0
0
0
Rep
0
M Vouches
0
0
0
Vouches
0
Posts
104
Likes
37
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 400 XP
On using Visual Basic, one of the most common control used to display a Date and Time is DateTimePicker, DateTimePicker is just like a combobox. If you click a dropdown arrow it displays a month calendar. And using this control it allows you to select Date and Time by modifying the format properties of this control.

This time let’s create a new project called “DateTimePicker”. Then add four DateTimePicker and button control from the toolbox. Then arrange it same as shown below:

datetimepicker.png


Then we will change the Format property of DateTimePicker2 to “short”, DateTimePicker3 to “Time” and the DateTimePicker3 to “Custom”. Next, we will add some code to the show button in line with every DateTimePicker. This code will help programmer to get text or value from the DateTimePicker selected by the user and store in some or Database.

This is for DateTimePicker1
  1. Private

    Sub

    Button1_Click(

    ByVal

    sender As

    System.

    Object

    , ByVal

    e As

    System.

    EventArgs

    )

    Handles

    Button1.

    Click
  2. MsgBox

    (

    DateTimePicker1.

    Text

    )
  3. End

    Sub

Output:
date1.png


This is for DateTimePicker2
  1. Private

    Sub

    Button2_Click(

    ByVal

    sender As

    System.

    Object

    , ByVal

    e As

    System.

    EventArgs

    )

    Handles

    Button2.

    Click
  2. MsgBox

    (

    DateTimePicker2.

    Text

    )
  3. End

    Sub

Output:
date2.png


This is for DateTimePicker3
  1. Private

    Sub

    Button3_Click(

    ByVal

    sender As

    System.

    Object

    , ByVal

    e As

    System.

    EventArgs

    )

    Handles

    Button3.

    Click
  2. MsgBox

    (

    DateTimePicker3.

    Text

    )
  3. End

    Sub

Output:
date3.png


This is for DateTimePicker4
  1. Private

    Sub

    Button4_Click(

    ByVal

    sender As

    System.

    Object

    , ByVal

    e As

    System.

    EventArgs

    )

    Handles

    Button4.

    Click
  2. MsgBox

    (

    DateTimePicker4.

    Text

    )
  3. End

    Sub

Output:
date4.png


Book traversal links for DateTimePicker Control

  • ‹ Custom Functions
  • Up
  • Dates and Times ›

 

440,010

316,559

316,568

Top