Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Password Verifier all alphabetic problem?

$
0
0
Hi I am having a problem with my password verifer. Right now, with the code I have, everything works except if the password is all alphabetic characters(the password is supposed to include at least one alphabetic and at least one numeric digit) I have been working on this code for a while, anyone have any suggestions on how to display an error message if the password that is entered is just alphabetic characters? Thanks for any input!

    

Function IsValid()

        'Declare variables
        Dim strInput As String
        Dim password As Boolean = False
        Dim Character As Char
        Dim intLenth As Integer

        While Not password

            strInput = InputBox("Please enter one password at a time.")

            'For Next loop
            For intLenth = 6 To strInput.Length - 1
                Character = strInput.Chars(intLenth)
                'Checking that there is a digit in the passwords
                If Not Char.IsDigit(Character) Then
                    password = True
                    Exit For
                End If
            Next

            'If statement that displays a message if a password is valid or not
            If password Then
                lstBox1.Items.Add("This password is valid!")
            Else
                MessageBox.Show("Your password must be six characers long and contain one numeric digit and one alphabetic character", "Invalid Password!")
            End If

        End While
        Return IsValid()
    End Function


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>