Ciao, la seguente funzione genera un codice alfanumerico random:
Succede però che ogni tanto la funzione genera lo stesso codice alfanumerico e mi crea confusione nello script; cosa mi consigliate di fare:codice:Function RandomPW(myLength) Const minLength = 6 Const maxLength = 20 Dim X, Y, strPW If myLength = 0 Then Randomize myLength = Int((maxLength * Rnd) + minLength) End If For X = 1 To myLength Y = Int((3 * Rnd) + 1) '(1) Numeric, (2) Uppercase, (3) Lowercase Select Case Y Case 1 Randomize strPW = strPW & CHR(Int((9 * Rnd) + 48)) Case 2 Randomize strPW = strPW & CHR(Int((25 * Rnd) + 65)) Case 3 Randomize strPW = strPW & CHR(Int((25 * Rnd) + 97)) End Select Next RandomPW = strPW End Function nr_random = RandomPW(10)
1) Aumentare il numero dei caratteri generati?
2) Controllare che il codice non sia già presente nel db e se in caso affermativo generare un secondo codice ?
Grazie

Rispondi quotando