Page 1 of 1

How to make a Password Generator

Posted: Mon Sep 05, 2011 2:11 pm
by splitedchill
Hello and Welcome to my first Tutorial

First I'm apologize for my bad English an now we beginning with my first tutorial:


We make in my first tutorial a Password Generator with 2 functions the first Function is a password generation with no special character the 2'nd with special character.


First we make a new Project i named it Password Generator

Now we make a Form with this Tools

1 Textbox
1 Button
1 Checkbox

Now we coming to the code. To make the Password we make two Functions the first Functions is the code without special character the 2'nd with special character.

First Functions
Code: Select all
Public Function GenerateCode() As Object
        Dim intRnd As Object
        Dim intStep As Object
        Dim strName As Object
        Dim intNameLength As Object
        Dim intLenght As Object
        Dim strInputString As Object

        strInputString = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

        intLenght = Len(strInputString)

        intNameLength = 10

        Randomize()

        strName = ""

        For intStep = 1 To intNameLength
            intRnd = Int((intLenght * Rnd()) + 1)

            strName = strName & Mid(strInputString, intRnd, 1)
        Next
        GenerateCode = strName
    End Function
Now come the Functions with special characters but you can copy the first code but you write some more characters here
Code: Select all
 strInputString = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
This is the code without special characters here are the code with:
Code: Select all
 strInputString = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"§$%&/()=?`-_.,;<>|°^"
You can make very more....

Here the special characters code in one:
Code: Select all
Public Function GenerateCodeSonder() As Object

        Dim intRnd As Object
        Dim intStep As Object
        Dim strName As Object
        Dim intNameLength As Object
        Dim intLenght As Object
        Dim strInputString As Object

        strInputString = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ§$%&/()=?"

        intLenght = Len(strInputString)

        intNameLength = 10

        Randomize()

        strName = ""

        For intStep = 1 To intNameLength
            intRnd = Int((intLenght * Rnd()) + 1)

            strName = strName & Mid(strInputString, intRnd, 1)
        Next
        GenerateCodeSonder = strName
    End Function
Now we have to Functions and now we can make a If query
Code: Select all
If Checkbox1.Checked Then
    Textbox1.Text = GenerateCodeSonder()
Else
    Textbox1.Text = GenerateCode()
End if

Now this was my first Tutorial here i hope you like this Tutorial please give me Feedback!

Re: How to make a Password Generator

Posted: Mon Sep 05, 2011 2:15 pm
by MrAksel
You cant put an object as a string propertys index value. You should use = to set the value.

Re: How to make a Password Generator

Posted: Mon Sep 05, 2011 7:17 pm
by mandai
This code is valid and it will work as it is.

Re: How to make a Password Generator

Posted: Mon Sep 05, 2011 7:27 pm
by MrAksel
mandai wrote:
This code is valid and it will work as it is.
I cant remember when it became possible to use Textbox1.Text(Something) to set a.textboxs text

Re: How to make a Password Generator

Posted: Mon Sep 05, 2011 7:33 pm
by mandai
Right, that would be an incorrect usage example.
This would work:
Code: Select all
If Checkbox1.Checked Then
    Textbox1.Text = GenerateCodeSonder()
Else
    Textbox1.Text = GenerateCode()
End if

Re: How to make a Password Generator

Posted: Mon Sep 05, 2011 7:37 pm
by comathi
This is very useful, congrats on your first tut :D

Re: How to make a Password Generator

Posted: Mon Sep 05, 2011 9:29 pm
by splitedchill
mandai wrote:
Right, that would be an incorrect usage example.
This would work:
Code: Select all
If Checkbox1.Checked Then
    Textbox1.Text = GenerateCodeSonder()
Else
    Textbox1.Text = GenerateCode()
End if

Thanks for your correction!

I have change it!

Re: How to make a Password Generator

Posted: Fri Sep 09, 2011 4:27 am
by RonaldHarvey
Good job my friend, I put it in my apps it works. cooll;

Re: How to make a Password Generator

Posted: Mon Sep 12, 2011 10:10 pm
by gummybears
Cool, you stole source code from Collin