Separate speaker notes to accompany arrays in Visual Basic (arrayBasic):
This shows the department array implemented in Visual Basic.
This shows the output when the user entered a dept code. When the user entered 2, WOMENS was retrieved from the array. When the user entered 3, GIRLS was retrieved. Entering 4 got BOYS and entering 1 got MENS.
This shows the form that is used in this program. Note that it also shows the properties for the form.
This shows the form and properties for the Dept Code label.
This shows the textbox for the department code. It is called txtDeptCode. It also shows the properties associated with this textbox field.
This is the Command Button that will retrieve the name from the array based on the code the user enters. Again, I am showing the properties associated with the Command Button.
This shows the code in the program. Note that the code is grouped into Procedures. Some of the procedures are called by Clicking a Button on the form. The procedure Form_Load() is executed when the form is loaded. This procedure fills the array with the department names. These names can then be extracted from the array using the department number that the user inputs.
In this example, the code that is entered is moved to text if it is in the valid range of 1 to 4. Then it is used to index the array name, DeptName to get the correct department from the array.
Note that if the code is not valid, an error message is moved to the text box.