I have this code to generate a password with letters and digits:
Public Function GeneratePwd(ByVal tnLength As Integer) As String
Dim lcPassword As String = ""
Dim lnCounter As Integer = 0
Dim lnRandom As Integer = 0
For lnCounter = 1 To tnLength
If lnCounter = 1 Or Int(Rnd() * 100) Mod 2 = 0 Then
lnRandom = Int(Rnd() * 25) + 97
Else
lnRandom = Int(Rnd() * 9) + 48
End If
lcPassword = lcPassword + Chr(lnRandom)
Next
Return lcPassword
End Function
This code has been converted from VFP. However, this does not work very well in .NET. It practically always generates the same password. Anyone would have something better to recommend?