Penn Foster 037093 – Guaranteed 100% score
Data Types and Application
Logic
OVERVIEW
YOUR PROJECT
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. The login
process will use
■ A Boolean value to indicate success
■ Two parallel arrays for usernames and passwords (See
pages 492–495 in your textbook on using parallel
arrays.)
■ Three procedures that contain conditional and iterative
statements.
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.
a. Right-click the project name in Solution Explorer or
choose the Add New Item… option in the Project
menu.
b. In the Add New Item dialog, choose Module. Type
the name Main.vb in the Name text box at the
bottom.
3. Click the Add button (Figure 26).
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.
4. 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 what’s shown in Figure 27.
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 = {ªAdminº, ªClerkº,
ªManagerº}
Use the values P@ssword, pa$$word, and passw0rd as
items in the arrPasswords array. Use the assignment
operator and curly braces to modify the declaration as
follows:
Dim arrPasswords() As String = {ªP@sswordº, ªpa$$wordº,
ªpassw0rdº}
In the Login subroutine, make sure that the username
and password arguments are valid and match.
5. Set the blnLoggedIn variable to False. This is to ensure
that previous attempts are overwritten.
6. Use an If…Else statement. Using the logical operator
And, combine the return value from calling the
VerifyUsername and VerifyPassword functions.
7. If the username and password arguments are valid, then
make sure the value in the arrUsernames array matches
the value in the arrPasswords array.
8. 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.
When the task is complete, the Login function should be
defined as follows:
Sub Login(ByVal username As String, ByVal password As
String)
blnLoggedIn = False
If VerifyUsername(username) And VerifyPassword(password)
Then
‘Find index for username
Dim userIndex As Integer
For loopIndex = 0 To arrUsernames.Length . 1
If arrUsernames(loopIndex) = username Then
userIndex = loopIndex
Exit For
End If
Next
‘Check for password match
If arrPasswords(userIndex) = password Then
blnLoggedIn = True
Else
MessageBox.Show(“Incorrect password.”)
End If
Else
MessageBox.Show(“Incorrect password.”)
End If
End Sub
9. 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.
10. Save your work.
11. In the LoginForm.vb, find the subroutine
btnLogin_Click.
12. 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 on the LoginForm.vb
file in Solution Explorer and double-click on the Login
button on the form.
13. Navigate to the btnLogin_Click subroutine.
14. 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.
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, “ & _
txtUsername.Text, “Logged In.”)
End If
15. You should get an error message using the blnLoggedIn
variable. Later in your course, there will be a discussion
on access modifiers, but for right now, just know that
you need to change the Dim keyword to Friend.
Open the Main.vb file.
16. Modify the blnLoggedIn declaration as follows:
Friend blnLoggedIn As Boolean
Save your work and debug the application. See what
happens when you type in an incorrect username and
password.
17. Make sure the application works as intended.
SUBMISSION GUIDELINES
To submit your project, you must provide the following two
files:
■ Main.vb
■ LoginForm.vb
To find these files, you should go to the directory where you
saved the GroceryApp project. To determine this path, click
on GroceryApp in the Solution Explorer panel. Copy the
value for the Project Folder property in the Properties
panel. In Windows Explorer, paste the file path and hit the
Enter key. Copy both the Main.vb and LoginForm.vb files to
your desktop or any other temporary location.
Use the following procedure to submit your project online:
1. Log in to view your student homepage and go to the
My Courses page.
2. Click on Take Exam next to the lesson you’re working on.
3. Attach your files as follows:
a. Click on the Browse box.
b. Locate the file you wish to attach.
c. Double-click on the file.
d. Click Upload File.
e. If you have more than one file to attach, repeat
steps a–d for each file.
4. Enter your e-mail address in the box provided.
(Note: Your e-mail address is required for online
submissions.)
5. If you wish to include comments about this project to
your instructor, enter your comments in the Message
box.
6. Click on Submit Files.
GRADING CRITERIA
Your project will be graded using the following guidelines.
■ The code contains the correct variables
and procedures. 160 points
■ The logic of the procedures is correct. 120 points
■ The Login button works as expected. 110 points
■ Both source code files are included. 110 points
TOTAL 100 points
* You can also use 2CO option if you want to purchase through Credit Cards/Paypal but make sure you put the correct billing information otherwise you wont be able to receive any download link.
* Your paypal has to be pre-loaded in order to complete the purchase or otherwise please discuss it with us at [email protected].
* As soon as the payment is received, download link of the solution will automatically be sent to the address used in selected payment method.
* Please check your junk mails as the download link email might go there and please be patient for the download link email. Sometimes, due to server congestion, you may receive download link with a delay.
* All the contents are compressed in one zip folder.
* In case if you get stuck at any point during the payment process, please immediately contact us at [email protected] and we will fix it with you.
* We try our best to reach back to you on immediate basis. However, please wait for atleast 8 hours for a response from our side. Afterall, we are humans.
* Comments/Feedbacks are truely welcomed and there might be some incentives for you for the next lab/quiz/assignment.
* In case of any query, please donot hesitate to contact us at [email protected].
* MOST IMPORTANT Please use the tutorials as a guide and they need NOT to be used for any submission. Just take help from the material.
******************************************** Good Luck ***************************************************
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.