GRAPHICAL USER INTERFACE FOR WINDOWS FORMS
You now have the basic GUI skills to make the GroceryApp project a multiple-form application. This project will assess your understanding of using controls, menus, and handling multiple forms. Make sure that you follow all directions completely and verify your results before submitting the project. Remember to include all required components in your solution.
Note: You’ll use the output of this project in the graded project for Lesson 5.
In the graded project for Lesson 3, you added grocery classes to the GroceryApp project. In this project, you’ll add a form with controls and menus to allow users to add grocery items to the shopping bas¬ket. You’ll also set the startup form and manage the login form.
1. In Visual Studio, load the GroceryApp project that you completed in Lesson 3. If this isn’t available, then you’ll need to ask your instructor for the finished Lesson 3 project.
2 Add a new form to the project named GroceryItemForm.
3. Add controls to GroceryItemForm to match the layout shown in Figure 31.
form contains two menus, four Label controls, two TextBox controls, a NumericUpDown control, a ComboBox control, a GroupBox component, a RichTextBox control, and a Button control.
1. Modify the design-time properties of the form and its controls using the information in Table 3.
GroceryItemForm Text Grocery Item TextBox2 TabIndex 0
GroceryItemForm Text lblScanNumber NumericUpDown1 (Name) numPrice
Label1 Text &Scan: NumericUpDown1 DecimalPlaces 2
Label2 (Name) lblBrandName NumericUpDown1 1
Label2 Text &Name: TabIndex
Label3 (Name) lblPrice ComboBox1 (Name) cboAisle
Label3 Text &Price: ComboBox1 DropDownStyle DropDownList
Label4 (Name) lblAisle ComboBox1 Items Bakery
Label4 Text A&isle: ComboBox1 TabIndex 2
GroupBox1 (Name) grpDescription RichTextBox1 (Name) txtDescription
GroupBox1 Text &Description RichTextBox1 TabIndex 3
TextBox1 (Name) txtScanNumber Button1 (Name) btnAddToBasket
TextBox1 ReadOnly True Button1 Text A&dd to Basket
TextBox1 TabStop False Button1 TabIndex 4
TextBox2 (Name) txtBrandName
2. Add the option E&xit to the Application menu.
3. Add the options A&dd and &View in the Basket menu.
4. Save your work on GroceryItemForm.vb.
5. Open the design view of LoginForm.vb.
6. Set the AcceptButton and CancelButton properties on LoginForm to the buttons btnLogin and btnCancel, respectively.
7. Set the PasswordChar property to * on txtPassword.
8. Set the TabIndex property for the two TextBox controls to 0 and 1, respectively.
9. In the Click event of btnCancel button, end the application.
10. Save these changes on LoginForm.vb.
11. Open GroceryItemForm.vb.
12. In the form’s Load event, display the login form modally and exit the application.
13. In the Click event of the btnAddToBasket button, perform the following steps:
a. Create a GroceryItem object using the values from the controls and add it to the basket variable. Note: Remember the basket variable is the GroceryBasket collection.
b. Verify that all controls except txtScanNumber contain a value.
c. Set the value of the txtScanNumber control using the following code:
txtScanNumber.Text 5 _
txtBrandName.Text.Substring(0, 3) & “1019”
d. Instantiate the GroceryItem class, using the control values.
e. Use the following expression to set the Aisle property. The expression con¬verts the text into an Aisle enumeration.
f. Add the GroceryItem object to the basket variable.
14. In the Click event of the Exit menu item, end the application.
15. Have the btnAddToBasket_Click method handle the Click event of AddToolStripMenuItem as well.
16. In the Click event of the View menu item, display all of the items in the bas¬ket variable in an informational message box. You need only display the Aisle, ScanNumber, and BrandName properties.
17. Set GroceryItemForm as the startup form.
18. Save and run the application. Verify that all controls and menus work correctly.
You don’t need to log in successfully to test the application. If you click the Close button in the top-right corner of the login form, you can skip the login process. This is by design in this case, but in a real-world application, this would be considered a serious security breach.
19. Test your work.
Your project will be graded using the following rubric:
Exemplary (4) Proficient (3) Fair (2) Poor (1) Not Evident (0)
The GroceryItemForm contains the required controls and layout. The GroceryItemForm contains most of the required con-trols and layout. The GroceryItemForm contains some of the required con-trols and layout. The GroceryItemForm contains few of the required controls and layout. No evidence that the GroceryItemForm contains the required controls and layout.
The GroceryItemForm contains the required application logic. The GroceryItemForm contains most of the required appli-cation logic. The GroceryItemForm contains some of the required appli-cation logic. The GroceryItemForm contains little of the required application logic. No evidence that the GroceryItemForm contains the required application logic.
The LoginForm has been modified correctly. The LoginForm has been modified mostly correctly. The LoginForm has been mod¬ified somewhat correctly. The LoginForm has been modified poorly. There’s no evidence that the LoginForm has been modified correctly.
All source code files are included. Most source code files are included. Some source code files are included. Few source code files are included. There’s no evidence that the source code files are included.
Submitting Your Project
To submit your project, you must provide the following files:
To find these files, to the directory where you saved the GroceryApp project. To open the project directory, right-click GroceryApp in the Solution Explorer panel and choose the Open Folder in File Explorer option in the context menu. Copy the LoginForm.Designer.vb, GroceryItemForm.vb and GroceryItemForm.Designer.vb files to your desktop or any other temporary location.
Use the following procedure to submit your project online:
Each project is individually graded by your instructor and therefore takes up to a few weeks to grade.© PENN FOSTER, INC. 2017 PAGE 126 VISUAL BASIC P ROGRAMMER Graded Project
To submit your graded project, follow these steps:
1. Go to http://www.pennfoster.edu.
2. Log in to your student portal.
3. Click Take Exam next to the lesson you’re working on.
4. Follow the instructions provided to complete your exam.
Be sure to keep a backup copy of any files you submit to the school!
Any personal information received will only be used to fill your order. We will not sell or redistribute your information to anyone.
We will try our best to resolve the issue and if still persists we can discuss for a refund in case its required.