Question
With VBA, complete the following question 'Question 7. Sub SingleSignOn() '--- The following codes validate a User's password. 'Declare Variables Dim password As String, upperCase
With VBA, complete the following question
'Question 7. Sub SingleSignOn() '--- The following codes validate a User's password. 'Declare Variables Dim password As String, upperCase As String, letterCheck() As String, LeftChar As String Dim i As Integer, j As Integer, pwLength As Integer Dim passwordCheck As Boolean
i = 0 ' Initialize variable "passswordCheck" to False passwordCheck = False
Do Until passwordCheck Or i = 5 'Input password password = InputBox("Enter your password: ", "Password") pwLength = Len(password) 'passwordCheck = False LeftChar = Left(password, 1) 'Validate password ... If (pwLength >= 8) And (UCase(LeftChar) = LeftChar) And _ (InStr(password, "3") > 0 Or InStr(password, "7") > 0 Or InStr(password, "8") > 0 Or InStr(password, "9") > 0) Then passwordCheck = True 'Encrypt the Password as requested. Exit Do Else MsgBox "Password must be at least 8 chars long" & vbNewLine & "The leftmost Char must be Uppercase" & _ vbNewLine & "Password must contain either 3, 7, 8, 9" & vbNewLine, vbYesNoCancel passwordCheck = False ' Password is not valid i = i + 1 End If Loop 'Max of 5 attempt allowed... If i = 5 Then MsgBox ("Too many attempts ... Account is locked.") Else 'Password information MsgBox ("The length of the password is " & pwLength & " and the password is " & password & ".") End If 'Modify the script to: ' Allow the length of the password to be up to 12 characters. ' Allow up to 9 attempts. ' Encrypt the password in two steps as follows: ' i. prefix it with 'zabT', and suffix it with 'gtYO'. ' ii. swap the leftmost three characters of the passsord in (i) with the rightmost three charaters. ' Display the encrypted password in a MsgBox. End Sub
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started