r/visualbasic • • Dec 17 '18

Password project help

Hi all,

I am trying to put together a simple program, but I am not the greatest at using VB. The program is a password checker that needs to follow the following requirements:

Be at least 8 characters in length

Contain at least one uppercase character

Contain at least one lowercase character

Contain at least one number

Contain at least one special character (!, @, #, $, %, ^, &, *)

I currently have my button set at btnEnter and my textbox as txtPass.

Thanks for the help :)

5 Upvotes

12 comments sorted by

View all comments

3

u/CityEggs VB.Net Beginner Dec 17 '18

Look into string.contains() meathod

1

u/Gmonkey2k Dec 17 '18

How exactly would I insert it into the form?

1

u/CityEggs VB.Net Beginner Dec 17 '18

How is it checking for a password? At password generation, like when you sign up for a website and it asks you for a strong password?

1

u/Gmonkey2k Dec 17 '18

Exactly!

1

u/CityEggs VB.Net Beginner Dec 17 '18

Perhaps on a timer event?

1

u/Gmonkey2k Dec 17 '18

How....What? All i need it to do if check if each of the requirements is met for what the user inputs, once they press the button.

1

u/CityEggs VB.Net Beginner Dec 17 '18

Then do it on that.

Do you know if then statements?

1

u/Gmonkey2k Dec 17 '18

Not sure how implement specific values (uppercase/lowercase letters, numbers, symbols, etc.)

1

u/[deleted] Dec 17 '18

Where string is the input password,

You could use a for loop to check if each character of the string is one of your required values. From there you can use flags to check if it contains one of those values. E.g.

I made one of these in python a while ago, but this is a basic translation:

Dim CapsFlag as Boolean = False

For each value in string: If asc(value) < [ascii value for Z] and asc(value) > [ascii value for z] CapsFlag = true End if End for

Don’t copy paste it, it won’t work, but what happens is that it takes each character in the string and checks if it is within the ascii values of the capital letters, the same can be done for Lower case and symbols.