' Generate a random password with the specified length. The password will only ' contain digits and letters (either lowercase or uppercase)'' Example: generating a password of 8 chars' Dim password As String = GetRandomPassword(8)Function GetRandomPassword(ByVal length As Integer) As String Static rand As New Random Dim password As New System.Text.StringBuilder(length) For i As Integer = 1 To length Dim charIndex As Integer ' allow only digits and letters Do charIndex = rand.Next(48, 123) Loop Until (charIndex >= 48 AndAlso charIndex <= 57) OrElse (charIndex _ >= 65 AndAlso charIndex <= 90) OrElse (charIndex >= 97 AndAlso _ charIndex <= 122) ' add the random char to the password being built password.Append(Convert.ToChar(charIndex)) Next Return password.ToString()End Function
![Outage Reddit](https://www.devx.com/wp-content/uploads/Outage-Reddit-300x171.jpg)