Microsoft Visual Basic
Constants, arrays and enumerations exercise
Harder than average exercise

This Microsoft Visual Basic CONSTANTS, ARRAYS AND ENUMERATIONS exercise is provided to allow potential course delegates to assess their suitability for the Wise Owl VISUAL BASIC 2005 WINDOWS FORMS course only, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.

Exercise: Adding to list of preferences in combobox

A full answer to this exercise is provided as part of the training course!

1) Create a new form called frmPreferences which allows a user to view the existing list of preferences:
Exercise screen-shot 1250 Initially there are 4 choices
2) To populate your combo box, create an array variable and populate it when the form loads:
Exercise screen-shot 1251 Sample code to set the data source for the combo box to be our newly populated array
3) Now add code to the Add this suggestion button such that when a user types in a new suggestion in the relevant text box, it is added to the array, and the combobox list is brought up to date:
Exercise screen-shot 1252 If the user clicks as shown, the array will be redimensioned and the combo box datasource reset
Training exercise hint The Add button should work out the length of the Preferences array, redimension it to be one more than it used to be (preserving the original contents), then set this new array element to be the new suggestion typed in.
4) If you have time, add a LIST button which uses a FOR EACH ... NEXT  loop to accumulate the contents of the array in a string variable, then displays this (see the courseware manual for how to do this).
5) Close down any open forms.

Thank you for showing an interest in this Visual Basic 2005 Windows Forms training course! As mentioned above, full answers to this and other exercises are provided on the course. On all Wise Owl scheduled courses delegates can take away these model answers (together with their own efforts!) on a free USB stick.

All content � Wise Owl Business Solutions Ltd 2007.  All rights reserved.  Design by Branches.