Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello I need help with getting this program to work. There is waht I have so far

ID: 3935913 • Letter: H

Question

Hello I need help with getting this program to work. There is waht I have so far:

Public Class Form1


Private Sub btnVerify_Click(sender As Object, e As EventArgs) Handles btnVerify.Click
Dim strPassword As String = ""

strPassword = CStr(txtPassword.Text)
'see if it is valid

If IsValid(strPassword) = True Then
MessageBox.Show("The password is valid.")

ElseIf IsValid(strPassword) = False Then
MessageBox.Show("The password is invalid.")
End If

End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
'Close form
Me.Close()
End Sub


Function IsValid(ByVal strPassword As String) As Boolean
Dim intCount As Integer = 0

'make sure the password is at least 6 characters long
If strPassword.Length >= 6 Then

'goes through each character of the text and does the tests for each character
For Each c As Char In strPassword
'make sure there is at least 1 letter in the string
If Asc(c) >= 65 And Asc(c) <= 90 Or Asc(c) >= 97 And Asc(c) <= 122 Then
'make sure there is at least 1 number in the string
If Asc(c) >= 49 And Asc(c) <= 57 Then
Return True
Else
Return False
End If
Else
Return False
End If
Next
End If
Return False
End Function
End Class

Explanation / Answer

Public Class Form1

Private Sub btnVerify_Click(sender As Object, e As EventArgs) Handles btnVerify.Click
Dim strPassword As String = ""
strPassword = CStr(txtPassword.Text)
'see if it is valid
If IsValid(strPassword) = True Then
MessageBox.Show("The password is valid.")
ElseIf IsValid(strPassword) = False Then
MessageBox.Show("The password is invalid.")
End If
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
'Close form
Me.Close()
End Sub

Function IsValid(strPassword As String)As Boolean
Dim intCount As Integer = 0
Dim checker As New Regex("(?=^.{6,}$)(?=.*d)(?=.*[A-Z])(?=.*[a-z]).*$")
   if(checker.IsMatch(strPassword)) Then
       Return True;
   Else
       Return False;
   EndIf
End Function

End Class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote