How to Disable the Previous Date in the DateTimePicker Using VB.Net

Submitted by: 
Visitors have accessed this post 105 times.

In this tutorial, I will teach you how to disable the previous date in the datetimepicker using vb.net. This method the ability to remove the previous date in the datetimepicker and show the current and future dates. This program will help you if you are developing a booking system or a reservation system.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new windows form.
ps2

Step 2

Add the DateTimePicker and two buttons inside the form. It will look like this.
ps2

Step 3

Press F7 to open the code editor. In the code editor, create a sub-procedure for setting up the minimum date of the datetimepicker.

  1.  
  2. Private Sub mindate(ByVal str_date As String)
  3. DateTimePicker1.MinDate = str_date
  4. End Sub

Step 4

Double click an “Enable” button to open the click event handler of it and do the following code to enable the previous date of the datetimepicker.

  1.  
  2. mindate("01/01/1753")

Step 5

Double click a “Disable” button to open the click event handler of it and do the following code to disable the previous date of the datetimepicker.

  1.  
  2. mindate(Now)

The complete source code is included. You can download it and run it on your computer.
For any questions about this article. You can contact me @
Email – [email protected]
Mobile No. – 09305235027 – TNT
Or feel free to comment


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.