Sub code_aleatoire()
Randomize
carac = "ABCD1234"
code_alea = ""
For i = 1 To 10 '10 = longueur du code
nombre_aleatoire = Int(Len(carac) * Rnd) + 1
code_alea = code_alea & Mid(carac, nombre_aleatoire, 1)
Next
MsgBox code_alea
End Sub
Function AleaChaine(x As Long)
For i = 1 To x
re:
Randomize
char = ChrW(47 + (Rnd * 75))
If Not char = "[" Then If Not t Like char And Not char = vbCrLf Then t = t & char Else GoTo re
Next
AleaChaine = t
End Function
Sub test2()
MsgBox AleaChaine(20)
End Sub