Create a form where the user can enter text into a text box and have the result output into a label in a different font (make sure you aren't losing any characters). The input text box and output label can be cleared by pressing the "Esc" key, ready to enter new data. If the "Esc" key is pressed twice in succession (i.e. without entering any data between) stop the program.
Extension: This design has only one control which can get focus. Add some extra controls and adjust your code (if necessary) so that the "Esc" key still works as before (even if the user has moved the focus).
Extension: Try to solve the problem of losing text if you type too much.
Create a form with a picture box. Find 3 interesting pictures. Use a timer control to cycle the pictures every 2 seconds. The form closes when the picture is clicked. (hint: LoadPicture)
Extension: Have the user choose their own set of pictures at run time. Different sets of pictures will be set up in different directories (use the Common Dialog control).
Create a "welcome" form" which asks the user their name, then says "Hello <name>". The user is then given a choice (with option buttons) of translating fonts or viewing pictures. Link this form to your two previous forms. This form is stopped by clicking a suitable Command Button or Icon.
Extension: If you make a menu form which has only the frame containing the option controls you may find that the menu choice is made for you. Can you avoid this?
Build a form which will select each of the following exercises (this speeds up the demonstration). Have each exercise return to this form on completion.
Create a global module which contains arrays with the names of 5 countries and their capital city. (For simplicity choose countries and cities with one word names). Write a global procedure which assigns names to these arrays. (Essentially these are constants, but VB does not support arrays of constants.) Remember that the default range for arrays begins at 0. The procedure will need to be called when the initial form is loaded.
Search. Build a form where you can type in a country name and be given the capital city. Display an error message if the country typed is not in the array.
List matching. Build a form with two drop down lists (combo boxes type 0), one for countries and one for cities. When this form is loaded fill the lists from the arrays. If the user pulls down one of the lists and clicks on a country (or capital) the corresponding capital (or country) is displayed in the text box of the other list.
String handling. European names are usually written with the family name last, but for official purposes they are stored family name first, so families can be sorted together (is this really necessary these days?). Write a function which takes a name in "family name last" format and reverses it. Assume the name has only two words and is stored as a single string. The inverted string has a comma following the family name. (eg "Jim Underwood" becomes "Underwood, Jim").
Build a form to test your function. The tutor will check that you are actually using a function.
This page is maintained by Jim
Underwood who can be reached at
jim@socs.uts.edu.au.
This page was last updated on July 23rd 1999.
http://www-staff.socs.uts.edu.au/~jim/avb/exercises.html
![]()