VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Yet Another Random Password Generator

by Dragan Ristic (1 Submission)
Category: String Manipulation
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Tue 9th May 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Yet Another Random Password Generator

API Declarations


8x CheckBox
2x TextBox
1x Button


Rate Yet Another Random Password Generator



        Randomize()
        Return Int(((Upperbound - Lowerbound) + Lowerbound) * Rnd())
    End Function

    Private Function GetRandomCharacter(ByVal Number As Boolean, ByVal Lowercase As Boolean, ByVal Uppercase As Boolean, ByVal Other As Boolean)
        Dim NumberCharacters As String = "0123456789"
        Dim LowercaseCharacters As String = "abcdefghijklmnopqrstuvwxyz"
        Dim UppercaseCharacters As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        Dim OtherCharacters As String = "`~!@#$%^&*()-_=+[{]}\\|;:'\,<.>/? "
        Dim CharacterSet As String = ""
        If Number Then
            CharacterSet += NumberCharacters
        End If
        If Lowercase Then
            CharacterSet += LowercaseCharacters
        End If
        If Uppercase Then
            CharacterSet += UppercaseCharacters
        End If
        If Other Then
            CharacterSet += OtherCharacters
        End If
        Return CharacterSet.Chars(GetRandomNumber(0, CharacterSet.Length))
    End Function

    Private Function GeneratePassword(ByVal Length As Integer, ByVal FirstNumber As Boolean, ByVal FirstLowercase As Boolean, ByVal FirstUppercase As Boolean, ByVal FirstOther As Boolean, ByVal LatterNumber As Boolean, ByVal LatterLowercase As Boolean, ByVal LatterUppercase As Boolean, ByVal LatterOther As Boolean)
        Dim Password As String
        Dim Index As Integer = 1
        Password = GetRandomCharacter(FirstNumber, FirstLowercase, FirstUppercase, FirstOther)
        Do Until Index = Length
            Password += GetRandomCharacter(LatterNumber, LatterLowercase, LatterUppercase, LatterOther)
            Index += 1
        Loop
        Return Password
    End Function

    Private Sub ButtonGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonGenerate.Click
        TextBoxPassword.Text = GeneratePassword(TextBoxLength.Text, CheckBoxFirstNumber.Checked, CheckBoxFirstLowercase.Checked, CheckBoxFirstUppercase.Checked, CheckBoxFirstOther.Checked, CheckBoxLatterNumber.Checked, CheckBoxLatterLowercase.Checked, CheckBoxLatterUppercase.Checked, CheckBoxLatterOther.Checked)
    End Sub

Download this snippet    Add to My Saved Code

Yet Another Random Password Generator Comments

No comments have been posted about Yet Another Random Password Generator. Why not be the first to post a comment about Yet Another Random Password Generator.

Post your comment

Subject:
Message:
0/1000 characters