Tuesday, 17 January 2012

Generate Random Password using Array

For this we need 2 controls.        1. Label                 2.Button


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label1.Text = GenerateRandomPassword(6)
    End Sub


Public Shared Function GenerateRandomPassword(ByVal passwdLength As Integer) As String
        Dim CharsAllowed As String = "abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789"
        Dim charsArray As Char() = New Char(passwdLength - 1) {}
        Dim rd As New Random()
        For i As Integer = 0 To passwdLength - 1
            charsArray(i) = CharsAllowed(rd.[Next](0, CharsAllowed.Length))
        Next
        Return New String(charsArray)
    End Function

1 comment:

  1. SURRENDO TOMBULA - Titanium Stud Earrings
    Shop the titanium armor SURRENDO TOMBULA at TITIAN ART. Find quality new mens titanium watches & used SURRENDO 2020 ford ecosport titanium TOMBULA products at the best titanium headers online prices used ford escape titanium at!

    ReplyDelete