Valid or Invalid Date in VB.NET

Hi! In this tutorial, we will make a program that decides if a date is invalid or not. The main function that we will just going to use is the IsDate Function. This function checks if the given expression is a valid date and returns a boolean true or false. So, now let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add only one Textbox named TextBox1. Then add a button named Button1 labeled as "Click This" for us to know that the date we have entered in our TextBox is a valid date or not. You must design your layout like this: design 3. Now, put this code in Button1_Click. This will determine if the date is valid or not in our inputted textbox.
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2.         MsgBox(TextBox1.Text & " is a valid date: " & IsDate(TextBox1.Text))
  3.     End Sub

Explanation

We only use IsDate Function in vb.net to determine whether our input is a valid date or not. IsDate returns True if Expression is of the Date Data Type or can be converted to Date; otherwise, it returns False.IsDate returns True if Expression represents a valid date, a valid time, or a valid date and time.

Output:

A Valid Date output

Output:

An Invalid Date Note: There is no February 29, 2014 in our Calendar. output Download the source code below and try it! :) For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz

Add new comment