Can some point me in the right direction in converting VBA Module into C#. If been working on this all weekend with no luck.
Public Function fRandomPword(intStrLen As Integer, booUpperCase As Boolean)
Dim sngStopNum As Single
Dim sngStartNum As Single
Dim intLooper As Integer
Dim strNewPword As String
Dim intRndAscii As Integer
If Nz(intStrLen, 0) = 0 Then GoTo JumpOut:
'97 - 122 = lower case alphabet
'64 - 90 = upper case alphabet, change as needed
'determine if use upper or lower case
If booUpperCase = True Then
sngStopNum = 90
sngStartNum = 64
Else
sngStopNum = 122
sngStartNum = 97
End If
For intLooper = 1 To intStrLen
TryAgain:
Randomize
intRndAscii = (sngStopNum * Rnd) + 1
If (intRndAscii < (sngStartNum + 1)) Or (intRndAscii > sngStopNum) Then
GoTo TryAgain
Else
strNewPword = strNewPword & Chr(intRndAscii)
End If
Next intLooper
fRandomPword = strNewPword
JumpOut:
End Function
Public Function fRandomPword(intStrLen As Integer, booUpperCase As Boolean)
Dim sngStopNum As Single
Dim sngStartNum As Single
Dim intLooper As Integer
Dim strNewPword As String
Dim intRndAscii As Integer
If Nz(intStrLen, 0) = 0 Then GoTo JumpOut:
'97 - 122 = lower case alphabet
'64 - 90 = upper case alphabet, change as needed
'determine if use upper or lower case
If booUpperCase = True Then
sngStopNum = 90
sngStartNum = 64
Else
sngStopNum = 122
sngStartNum = 97
End If
For intLooper = 1 To intStrLen
TryAgain:
Randomize
intRndAscii = (sngStopNum * Rnd) + 1
If (intRndAscii < (sngStartNum + 1)) Or (intRndAscii > sngStopNum) Then
GoTo TryAgain
Else
strNewPword = strNewPword & Chr(intRndAscii)
End If
Next intLooper
fRandomPword = strNewPword
JumpOut:
End Function