MadhuSudhan  H N

MadhuSudhan H N

  • NA
  • 7
  • 3.2k

Random Password generation

Nov 26 2012 12:25 AM
 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim allowedChars As String = ""

        allowedChars = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,"
        allowedChars += "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,"
        allowedChars += "1,2,3,4,5,6,7,8,9,0,!,@,#,$,%,&,?"

        Dim sep As Char() = {","c}
        Dim arr As String() = allowedChars.Split(sep)
        Dim passwordString As String = ""
        Dim temp As String = ""
        Dim rand As New Random()

        For i As Integer = 0 To Convert.ToInt32(TextBox27.Text) - 1
            temp = arr(rand.[Next](0, arr.Length))
            passwordString += temp
        Next

        TextBox27.Text = passwordString

    End Sub

I am getting an error for the above Code


Input string was not in a correct format.

Answers (6)