Penn Foster 037848 – Grocery app, Functional Login Form with screenshots – Perfect Solution – Instant Delivery
GRADED PROJECT
DATA TYPES AND APPLICATION LOGIC
Overview
You’re ready to add further functionality to the GroceryApp project. This project will assess your understanding of using variables, arrays, modules, and procedures. 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.
In the graded project for Lesson 1, you created a login form using a Windows Forms Application project in Visual Studio. In this project, you’ll implement the login process.
Note: The output of this project will be used in the graded project for Lesson 3.
Instructions
1. In Visual Studio, load the GroceryApp project that you completed in Lesson 1. If this isn’t available, then you’ll need to ask your instructor for the finished Lesson 1 project.
2. Add a new module to the project.
a. Right-click the project name in Solution Explorer and choose Add > Module… or choose the Add Module… option in the Project menu.
b. Type the name Main.vb in the Name text box at the bottom. An example of what the screen should look like is shown in Figure 13.
c. Click the Add button.
3. In the Main module, you’ll perform the following actions.
a. Declare a Boolean variable named blnLoggedIn.
b. Declare two String arrays named arrUsernames and arrPasswords.
c. Declare a subroutine named Login that accepts two String parameters named username and password.
d. Declare two functions named VerifyUsername and VerifyPassword. The VerifyUsername function should accept a String parameter named username and return a Boolean value. The VerifyPassword function should accept a String parameter named password and return a Boolean value. When this task is completed, the source code editor should contain the code shown in Figure 14.© PENN FOSTER, INC. 2017 PAGE 56 VISUAL BASIC P ROGRAMMER Graded Project
FIGURE 13—Enter Main.vb in the location where modVerify.vb is shown and click Add.
FIGURE 14—Source Code Editor with Correct Code© PENN FOSTER, INC. 2017 PAGE 57 VISUAL BASIC P ROGRAMMER Graded Project
4 Save your work.
5. Use the values Admin, Clerk, and Manager as items in the arrUsernames array. Use the assignment operator and curly braces to modify the declaration as follows:
Dim arrUsernames() As String 5 {“Admin”, “Clerk”, “Manager”}
6. Use the values P@ssword, pa$$word, and passw0rd as items in the arrPass¬words array. Use the assignment operator and curly braces to modify the declaration as follows:
Dim arrPasswords() As String 5 {“P@ssword”, “pa$$word”, “passw0rd”}
7. In the Login subroutine, make sure that the username and password arguments are valid and match.
a. Set the blnLoggedIn variable to False. This is to ensure that previous attempts are overwritten.
b. Use an If…Else statement. Using the logical operator And, combine the return value from calling the VerifyUsername and VerifyPassword functions.
c. If the username and password arguments are valid, then make sure the value in the arrUsernames array matches the value in the arrPasswords array.
d. If the correct password is specified for the username, then set the blnLoggedIn variable to the value True. If not, then display an error message box.
e. When the task is complete, the Login function should be defined as follows:
Sub Login(username As String, password As String)
blnLoggedIn 5 False
If VerifyUsername(username) And VerifyPassword(password)
Then
‘Find index for username
Dim userIndex As Integer
For loopIndex 5 0 To arrUsernames.Length – 1
If arrUsernames(loopIndex) 5 username Then
userIndex 5 loopIndex
Exit For
End If
Next© PENN FOSTER, INC. 2017 PAGE 58 VISUAL BASIC P ROGRAMMER Graded Project
‘Check for password match
If arrPasswords(userIndex) 5 password Then
blnLoggedIn 5 True
Else
MessageBox.Show(“Incorrect password.”)
End If
End If
End Sub
8. Using what you know about search arrays, implement the VerifyUsername and VerifyPassword functions. They should return true if the username or password is found in the arrUsernames or arrPasswords array, respectively.
9. Save your work.
10. In LoginForm.vb, find the subroutine btnLogin_Click.
a. You can either right-click on the LoginForm.vb file in Solution Explorer and choose the View Code option in the context menu or double-click the LoginForm.vb file in Solution Explorer and double-click the Login button on the form.
b. Navigate to the btnLogin_Click subroutine.
11. Modify the contents of the btnLogin_Click button.
a. Call the Login subroutine in the Main module.
b. Use the blnLoggedIn variable to determine whether to display the message box.
c. The btnLogin_Click subroutine should resemble the following:
Main.Login(txtUsername.Text, txtPassword.Text)
If Main.blnLoggedIn Then
MessageBox.Show(“Thank you for logging in, “ & txtUs¬ername.Text, “Logged In.”)
Me.Close()
End If
You should get an error message using the blnLoggedIn variable. In the next les¬son, you’ll be introduced to access modifiers, but for right now, just know that you need to change the Dim keyword to Friend.© PENN FOSTER, INC. 2017 PAGE 59 VISUAL BASIC P ROGRAMMER Graded Project
12. Open the Main.vb file and modify the blnLoggedIn declaration as follows:
Friend blnLoggedIn As Boolean
13. Save your work and debug the application. See what happens when you type in an incorrect username and password.
14. Make sure the application works as intended.
Grading Criteria
The following rubric will be used to grade your project:
Exemplary (4) Proficient (3) Fair (2) Poor (1) Not Evident (0)
The code contains the correct vari¬ables and procedures. The code contains mostly correct variables and procedures. The code contains some-what correct variables and procedures. The code contains few correct vari¬ables and procedures. There’s no evidence of correct vari¬ables and procedures.
The logic of the procedures is correct. The logic of the procedures is mostly correct. The logic of the procedures is somewhat correct. The logic of the procedures is poor. There’s no evidence of correct logic of the procedures.
The Login but-ton works as expected. N/A N/A N/A There’s no evidence of the Login button working as expected.
Both source code files are included. One source file is included. N/A N/A No evidence of source code files is included.
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.