Dokki
Stealth Operative
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
In this tutorial, i will teach you how to create a program that validates an inputted date using C#, thus this will determine if a date is invalid or not. Here, we will use the IsDate Function.
So, now let's start this tutorial!
1. Let's start with creating a Windows Form Application in C# for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application and name your project as Valid or Invalid Date.
2. Next, add only one Textbox named TextBox1. Then add a button named Button1 labeled as "Validate" for us to know that the date we have entered in our TextBox is a valid date or not. You must design your interface like this:
3. Now, put this code in Button1_Click. This will determine if the date is valid or not in our inputted textbox.
This IsDate function in Information class here checks if the given expression is a valid date and returns a boolean true or false. 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.
Press F5 to run the program.
Output:
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
Download
So, now let's start this tutorial!
1. Let's start with creating a Windows Form Application in C# for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application and name your project as Valid or Invalid Date.
2. Next, add only one Textbox named TextBox1. Then add a button named Button1 labeled as "Validate" for us to know that the date we have entered in our TextBox is a valid date or not. You must design your interface like this:

3. Now, put this code in Button1_Click. This will determine if the date is valid or not in our inputted textbox.
- public
void
Button1_Click(
System
.
Object
sender, System
.
EventArgs
e)
- {
- MessageBox.
Show
(
TextBox1.
Text
+
" is a valid date: "
+
Information.
IsDate
(
TextBox1.
Text
)
)
;
- }
This IsDate function in Information class here checks if the given expression is a valid date and returns a boolean true or false. 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.
Press F5 to run the program.
Output:

Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
Download
You must upgrade your account or reply in the thread to view hidden text.