Exercise: Use conditions to check a form is correctly filled in

This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

The answer to the exercise will be included and explained if you attend the Wise Owl course listed below!

Category ==> Visual Basic 2010  (42 exercises)
Topic ==> Testing conditions  (2 exercises)
Level ==> Average difficulty
Course ==> Introduction to VB.NET
Before you can do this exercise, you'll need to download and unzip this file (if you have any problems doing this, click here for help).

You need a minimum screen resolution of about 700 pixels width to see our exercises. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Press CTRL + D to add the file called frmApplication.vb from the above folder into your project (or right click on the project and choose to add it as an existing item). 

Change your project's properties to make this the default form for your project.  When you run your project, you should see this:

Dating agency application form

Match.com it isn't, but it's a start ...

Add validation code to check that each text and combo box is filled in, that the age text boxes contain integers, and that each age is between sensible values (infants and centenarians don't date much ...).

If you find a text box with an invalid value, display an error message, use Focus() to leave the cursor in it and exit your subroutine.

Still got time and energy?  Add a message at the end to announce your choice to the world:

Final message box

An example of what you should see (would a fox really seek a cougar?).

 

That's it!  Close everything down and give yourself a pat on the back. 

This page has 0 threads Add post