I need to get the function code put in correctly and get the username and passwords to match in order to get the message box to come up.
Instructions** 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.
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.
You should get an error message using the blnLoggedIn variable.
Debug
AnyCPU
{33B57008-8AE6-4E7B-B70B-95667F64BD61}
WinExe
GroceryApp.My.MyApplication
GroceryApp
GroceryApp
512
WindowsForms
v4.6.1
true
AnyCPU
true
full
true
true
bin\Debug\
GroceryApp.xml
42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
AnyCPU
pdbonly
false
true
true
bin\Release\
GroceryApp.xml
42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
On
Binary
Off
On
Form
LoginForm.vb
Form
True
Application.myapp
True
True
Resources.resx
True
Settings.settings
True
LoginForm.vb
VbMyResourcesResXFileCodeGenerator
Resources.Designer.vb
My.Resources
Designer
MyApplicationCodeGenerator
Application.Designer.vb
SettingsSingleFileGenerator
My
Settings.Designer.vb
GroceryApp/App.config
GroceryApp/bin/Debug/GroceryApp.exe
GroceryApp/bin/Debug/GroceryApp.exe.config
GroceryApp/bin/Debug/GroceryApp.pdb
GroceryApp/bin/Debug/GroceryApp.xml
GroceryApp
A strongly-typed resource class, for looking up localized strings, etc.
Returns the cached ResourceManager instance used by this class.
Overrides the current thread’s CurrentUICulture property for all
resource lookups using this strongly typed resource class.
GroceryApp/Class1.vb
Public Class Class1
End Class
GroceryApp/GroceryApp.vbproj
Debug
AnyCPU
{33B57008-8AE6-4E7B-B70B-95667F64BD61}
WinExe
GroceryApp.My.MyApplication
GroceryApp
GroceryApp
512
WindowsForms
v4.6.1
true
AnyCPU
true
full
true
true
bin\Debug\
GroceryApp.xml
42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
AnyCPU
pdbonly
false
true
true
bin\Release\
GroceryApp.xml
42016,41999,42017,42018,42019,42032,42036,42020,42021,42022
On
Binary
Off
On
Form
LoginForm.vb
Form
True
Application.myapp
True
True
Resources.resx
True
Settings.settings
True
LoginForm.vb
VbMyResourcesResXFileCodeGenerator
Resources.Designer.vb
My.Resources
Designer
MyApplicationCodeGenerator
Application.Designer.vb
SettingsSingleFileGenerator
My
Settings.Designer.vb
GroceryApp/LoginException.vb
Public Class LoginException
End Class
GroceryApp/LoginForm.Designer.vb
Partial Class LoginForm
Inherits System.Windows.Forms.Form
‘Form overrides dispose to clean up the component list.
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
‘Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
‘NOTE: The following procedure is required by the Windows Form Designer
‘It can be modified using the Windows Form Designer.
‘Do not modify it using the code editor.
Private Sub InitializeComponent()
Me.lblUsername = New System.Windows.Forms.Label()
Me.lblPassword = New System.Windows.Forms.Label()
Me.txtUsername = New System.Windows.Forms.TextBox()
Me.txtPassword = New System.Windows.Forms.TextBox()
Me.btnLogin = New System.Windows.Forms.Button()
Me.btnCancel = New System.Windows.Forms.Button()
Me.SuspendLayout()
‘
‘lblUsername
‘
Me.lblUsername.AutoSize = True
Me.lblUsername.Location = New System.Drawing.Point(12, 9)
Me.lblUsername.Name = “lblUsername”
Me.lblUsername.Size = New System.Drawing.Size(55, 13)
Me.lblUsername.TabIndex = 0
Me.lblUsername.Text = “Username”
‘
‘lblPassword
‘
Me.lblPassword.AutoSize = True
Me.lblPassword.Location = New System.Drawing.Point(12, 42)
Me.lblPassword.Name = “lblPassword”
Me.lblPassword.Size = New System.Drawing.Size(56, 13)
Me.lblPassword.TabIndex = 1
Me.lblPassword.Text = “Password:”
‘
‘txtUsername
‘
Me.txtUsername.AcceptsReturn = True
Me.txtUsername.Location = New System.Drawing.Point(73, 6)
Me.txtUsername.Name = “txtUsername”
Me.txtUsername.Size = New System.Drawing.Size(100, 20)
Me.txtUsername.TabIndex = 2
‘
‘txtPassword
‘
Me.txtPassword.Location = New System.Drawing.Point(73, 38)
Me.txtPassword.Name = “txtPassword”
Me.txtPassword.Size = New System.Drawing.Size(100, 20)
Me.txtPassword.TabIndex = 3
‘
‘btnLogin
‘
Me.btnLogin.Location = New System.Drawing.Point(197, 3)
Me.btnLogin.Name = “btnLogin”
Me.btnLogin.Size = New System.Drawing.Size(75, 23)
Me.btnLogin.TabIndex = 4
Me.btnLogin.Text = “Login”
Me.btnLogin.UseVisualStyleBackColor = True
‘
‘btnCancel
‘
Me.btnCancel.Location = New System.Drawing.Point(197, 36)
Me.btnCancel.Name = “btnCancel”
Me.btnCancel.Size = New System.Drawing.Size(75, 23)
Me.btnCancel.TabIndex = 5
Me.btnCancel.Text = “Cancel”
Me.btnCancel.UseVisualStyleBackColor = True
‘
‘LoginForm
‘
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(284, 87)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnLogin)
Me.Controls.Add(Me.txtPassword)
Me.Controls.Add(Me.txtUsername)
Me.Controls.Add(Me.lblPassword)
Me.Controls.Add(Me.lblUsername)
Me.Name = “LoginForm”
Me.Text = “Please Login”
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents lblUsername As Label
Friend WithEvents lblPassword As Label
Friend WithEvents txtUsername As TextBox
Friend WithEvents txtPassword As TextBox
Friend WithEvents btnLogin As Button
Friend WithEvents btnCancel As Button
End Class
GroceryApp/LoginForm.resx
text/microsoft-resx
2.0
System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
GroceryApp/LoginForm.vb
Public Class LoginForm
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles lblUsername.Click, btnLogin.Click
If Main.blnLoggedIn Then
MessageBox.Show(“Thank you for logging in, “ & txtUsername.Text, “Logged In.”)
Me.Close()
End If
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Application.Exit()
End Sub
End Class
GroceryApp/Main.vb
Module Main
Friend blnLoggedIn As Boolean
Dim arrUsernames() As String = {“Admin, Clerk, Manager”}
Dim arrPasswords() As String = {“P@ssword, pa$$word, and passw0rd”}
Sub Login(username As String, 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
End If
End Sub
Function VerifyUsername(username As String) As Boolean
End Function
Function VerifyPassword(password As String) As Boolean
End Function
End Module
GroceryApp/My Project/Application.Designer.vb
‘——————————————————————————
‘
‘ This code was generated by a tool.
‘ Runtime Version:4.0.30319.42000
‘
‘ Changes to this file may cause incorrect behavior and will be lost if
‘ the code is regenerated.
‘
‘——————————————————————————
Option Strict On
Option Explicit On
Namespace My
‘NOTE: This file is auto-generated; do not modify it directly. To make changes,
‘ or if you encounter build errors in this file, go to the Project Designer
‘ (go to Project Properties or double-click the My Project node in
‘ Solution Explorer), and make changes on the Application tab.
‘
Partial Friend Class MyApplication
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
Me.IsSingleInstance = false
Me.EnableVisualStyles = true
Me.SaveMySettingsOnExit = true
Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses
End Sub
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.GroceryApp.LoginForm
End Sub
End Class
End Namespace
GroceryApp/My Project/Application.myapp
true
Form1
false
0
true
0
0
true
GroceryApp/My Project/AssemblyInfo.vb
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
‘ General Information about an assembly is controlled through the following
‘ set of attributes. Change these attribute values to modify the information
‘ associated with an assembly.
‘ Review the values of the assembly attributes
‘The following GUID is for the ID of the typelib if this project is exposed to COM
‘ Version information for an assembly consists of the following four values:
‘
‘ Major Version
‘ Minor Version
‘ Build Number
‘ Revision
‘
‘ You can specify all the values or you can default the Build and Revision Numbers
‘ by using the ‘*’ as shown below:
‘
GroceryApp/My Project/Resources.Designer.vb
‘——————————————————————————
‘
‘ This code was generated by a tool.
‘ Runtime Version:4.0.30319.42000
‘
‘ Changes to this file may cause incorrect behavior and will be lost if
‘ the code is regenerated.
‘
‘——————————————————————————
Option Strict On
Option Explicit On
Namespace My.Resources
‘This class was auto-generated by the StronglyTypedResourceBuilder
‘class via a tool like ResGen or Visual Studio.
‘To add or remove a member, edit your .ResX file then rerun ResGen
‘with the /str option, or rebuild your VS project.
”’
”’
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
”’
”’
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager(“GroceryApp.Resources”, GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
”’
”’ resource lookups using this strongly typed resource class.
”’
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set(ByVal value As Global.System.Globalization.CultureInfo)
resourceCulture = value
End Set
End Property
End Module
End Namespace
GroceryApp/My Project/Resources.resx
text/microsoft-resx
2.0
System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
GroceryApp/My Project/Settings.Designer.vb
‘——————————————————————————
‘
‘ This code was generated by a tool.
‘ Runtime Version:4.0.30319.42000
‘
‘ Changes to this file may cause incorrect behavior and will be lost if
‘ the code is regenerated.
‘
‘——————————————————————————
Option Strict On
Option Explicit On
Namespace My
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
#Region “My.Settings Auto-Save Functionality”
#If _MyType = “WindowsForms” Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = “WindowsForms” Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
Friend Module MySettingsProperty
Friend ReadOnly Property Settings() As Global.GroceryApp.My.MySettings
Get
Return Global.GroceryApp.My.MySettings.Default
End Get
End Property
End Module
End Namespace
GroceryApp/My Project/Settings.settings
GroceryApp/obj/Debug/DesignTimeResolveAssemblyReferences.cache
GroceryApp/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
GroceryApp/obj/Debug/GroceryApp.exe
GroceryApp/obj/Debug/GroceryApp.LoginForm.resources
GroceryApp/obj/Debug/GroceryApp.pdb
GroceryApp/obj/Debug/GroceryApp.Resources.resources
GroceryApp/obj/Debug/GroceryApp.vbproj.CoreCompileInputs.cache
46a45a4e6653315d35b1a3d7e8e8873fc291d846
GroceryApp/obj/Debug/GroceryApp.vbproj.FileListAbsolute.txt
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\bin\Debug\GroceryApp.exe.config
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\bin\Debug\GroceryApp.exe
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\bin\Debug\GroceryApp.pdb
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\bin\Debug\GroceryApp.xml
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\obj\Debug\GroceryApp.vbprojResolveAssemblyReference.cache
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\obj\Debug\GroceryApp.LoginForm.resources
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\obj\Debug\GroceryApp.Resources.resources
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\obj\Debug\GroceryApp.vbproj.GenerateResource.Cache
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\obj\Debug\GroceryApp.vbproj.CoreCompileInputs.cache
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\obj\Debug\GroceryApp.exe
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\obj\Debug\GroceryApp.xml
C:\Users\Owner\source\repos\GroceryApp\GroceryApp\obj\Debug\GroceryApp.pdb
GroceryApp/obj/Debug/GroceryApp.vbproj.GenerateResource.Cache
GroceryApp/obj/Debug/GroceryApp.vbprojResolveAssemblyReference.cache
GroceryApp/obj/Debug/GroceryApp.xml
GroceryApp
A strongly-typed resource class, for looking up localized strings, etc.
Returns the cached ResourceManager instance used by this class.
Overrides the current thread’s CurrentUICulture property for all
resource lookups using this strongly typed resource class.
GroceryApp/obj/Debug/TempPE/My Project.Resources.Designer.vb.dll
GroceryApp.sln
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2020
MinimumVisualStudioVersion = 10.0.40219.1
Project(“{F184B08F-C81C-45F6-A57F-5ABD9991F28F}”) = “GroceryApp”, “GroceryApp\GroceryApp.vbproj”, “{33B57008-8AE6-4E7B-B70B-95667F64BD61}”
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{33B57008-8AE6-4E7B-B70B-95667F64BD61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33B57008-8AE6-4E7B-B70B-95667F64BD61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33B57008-8AE6-4E7B-B70B-95667F64BD61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33B57008-8AE6-4E7B-B70B-95667F64BD61}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B6169252-A932-49DC-A3AC-B1415754DEA1}
EndGlobalSection
EndGlobal
GroceryApp – Copy.sln
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2020
MinimumVisualStudioVersion = 10.0.40219.1
Project(“{F184B08F-C81C-45F6-A57F-5ABD9991F28F}”) = “GroceryApp”, “GroceryApp\GroceryApp.vbproj”, “{33B57008-8AE6-4E7B-B70B-95667F64BD61}”
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{33B57008-8AE6-4E7B-B70B-95667F64BD61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33B57008-8AE6-4E7B-B70B-95667F64BD61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33B57008-8AE6-4E7B-B70B-95667F64BD61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33B57008-8AE6-4E7B-B70B-95667F64BD61}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B6169252-A932-49DC-A3AC-B1415754DEA1}
EndGlobalSection
EndGlobal