Programming | | Notes on ListBox, ComboBox, and NumericUpDown:
ListBox control:The ListBox control enables you to display a list of data in a single or multiple data item, such as a list of names or dates selected. This control is like the ComboBox control but does not have a drop-down list. The data inside a ListBox is display within the open text window. A ListBox can be used to get a user’s single response from a list of choices. ListBoxes are mostly used with other items to help displayed the input and output. In addition, ListBox doesn’t require a default selection. The standard prefix for a ListBox is "lst"

ComboBox control: A ComboBox, or drop-down list box, is similar to a ListBox, but it takes up less space . The “combo” in a combo box basically comes from a “combination” of an editable text box and a drop-down list. Visual Basic automatically handles the opening, closing, and scrolling of the list box. All you do as a programmer is create the combo box using the ComboBox control in the Toolbox, set the Text and Items property to provide directions and user’s combo box selection. The standard prefix for a ComboBox is "cbo"

NumericUpDown control: A NumericUpDown control is quite simple. It is a control that displays number values. The Windows Form NumericUpDown control looks like a combination of a text box and a pair of arrows that the user can click to adjust a value. The control displays and sets a single numeric value from a list of choices. The user can increment and decrement the number by clicking up and down buttons or by pressing the UP and DOWN ARROW keys or by typing a number. Clicking the UP ARROW key moves the value toward the maximum; clicking the DOWN ARROW key moves the value toward the minimum. An example where this kind of control might be useful is for a volume control on a music player. Numeric up-down controls are used in many Windows control panel applications.

Example Problem 13 (The T-Shirt Program): This is a simple program that will use the new controls with the IFTHENELSE structure to find a person's total price for purchase of T-Shirts that are sold at the school. This program will use the new controls: ListBox, ComboBox, GroupBox, RadioButton, and NumericUpDown control. An example of the form is given below with the supporting code. Please follow the steps below in creating this program. Please remember to place your name somewhere at the bottom of this form. In addition, please review how the ToString("c") is applied with the written code. Save program as Example 13 and put the form and code stapled together and turn in.

Step 1 (placing the controls on the form):
1. Load up Visual Basic program and create a new Window Application project. Save program as Example 13.
2. Place a GroupBox Control on the form as shown:
3. Place two RadioButton Controls on the form inside the GroupBox Control as shown:
4. Then place two Labels, one ComboBox, one NumericUpDown, and one ListBox Control on the form to the right of the GroupBox Control as shown:
5. Finally, finish up the bottom half of the form by placing three Buttons and another Label and TextBox control on the form as shown:

Step 2 (Changing each control's properties):
The form below shows what the form should look like. You will use the Text properties to change each control on the Form. Working with the ComboBox control you will need to place four strings inside the String Collection Editor. By clicking on the Item property the String Collection Editor window will open up, then write the four strings (Small, Medium, Large, and X-Large) inside this window. Once you finish click "OK" button.

Step 3 (Writing the code):
The major part of the code will be written within the Button1 control, which is the Enter Button. But, you will need to place some code commands inside the RadioButtons and also use two Global variables outside of a specific event procedure (at the top of the code window). It is good practice to place all Global variables right below the FlowerBox of the code. In short, the purpose of a Global variable is that Visual Basic .NET allows that variable type to be used with other event procedures as shown in this program code. Both the RadioButtons and Button1 will use the variable "subTotal" and "Shirtcolor" within each of their event procedures.

1. Place the FlowerBox and Global variable in the code. To bring the code up without clicking on any controls, just click on the View Code button in the Solution Explorer window. Complete the steps as shown below:

2. Next, you will assign each of the RadioButton controls a code that will define each of their event procedures for each of the options when they are selected during run time. You will click on each of the RadioButtons (RadioButton1 and RadioButton2) and place a value for Shirtcolor (the string "Shirtcolor" had just been assigned as a Global variable above). Again, you must write the code within each Private Sub for each RadioButton. Simply triple click each RadioButton on the form and the program will pull in each of the Private Sub event procedures. Once you click on each RadioButton (on your form) review and complete the steps as shown, below. Notice that each RadioButton will have a different string value for Shirtcolor.

3. Now it's time to write the code for the calculations on purchasing T-Shrits. This event procedure will occur within the Button1 control. So again, simply triple click on the Button1 control so the program will pull in the Private Sub for the Button1 control. Once you click on the Button1 (on your form) review and complete the steps as shown below. You will notice that the code has four IFTHENELSE control structures. These tests are designed to place a value for each size of shirt. Notice at the bottom of the event procedure code is the total cost and the use of the ToString("c") function. Visual Basic .NET uses this to format your output to represent currency. Also notice the use of the TextBox1 and ListBox1 coded procedure. The TextBox1 line will post the total and ListBox1 line will display all transactions that have been made while the program is running.

4. This code should be pretty much straight forward. Bring forth both of the Button2 and Button3 controls and complete the code to clear all of the controls during run time and exit the program. Please review the correct commands given to each of the RadioButtons, ListBox, and ComboBox which will clear these controls during run time. The ComboBox will put the text "[Select One]" inside the control

Working with Multiple Forms: Before you complete this problem you are asked to add another form to this program. Again, you learned how to do this llast example problem. And since we spent time creating a copyright form let's try to use this one by adding this existing form to this project. Please follow the steps below to add this existing copyright form.

1. First let's add a button to the form. Call it copyright and rename it to btnCopyright

2. Before you start writing the code try to pull in the copyright form that you created in Example 10. Click on and select the Add Existing Item on the tool bar. You will need to look in the Visual Basic .NET folder called Example 10 that you developed already. You will need to select the file called copyright.vb. Once you select the copyright.vb file you should notice that you now have two forms in your Solution Explorer. You should not have to write any code for this form since that occured already. But you will have to code the copyright button that calls for the program to open this form.

3. Again this is the code that you should follow to open up the copyright form.

4. Print out the code and the print screen of this form and turn in together.