Maintenant existe-t-il un code qui permet de générer par exemple un chiffre, puis une lettre, puis encore un chiffre, aléatoirement ( sans ordre respectif)
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim chiffres As String = "123456789" Dim lettres As String = "abcdefghijklmnopqrstuvwxz" Dim rnd As New Random Dim unelettre As Char Dim unchiffre As Integer unelettre = Convert.ToChar(lettres.Substring(rnd.Next(0, lettres.Length), 1)) unchiffre = Convert.ToInt32(chiffres.Substring(rnd.Next(0, chiffres.Length), 1))
' form 1 : lettres / nombres aléatoires Option Explicit Sub Form_Load() ' form1 + 3 objets Label1 = "" Command1.Caption = "écrit" Command2.Caption = "efface" End Sub Sub Command1_Click() ' écrit Randomize Select Case Int((2 - 1 + 1) * Rnd + 1) ' 1 ou 2 Case 1 Randomize Label1 = Label1 & Chr(Int((57 - 49 + 1) * Rnd + 49)) ' chiffre Case 2 Randomize Label1 = Label1 & Chr(Int((122 - 97 + 1) * Rnd + 97)) ' lettre End Select End Sub Sub Command2_Click(): Label1 = "": End Sub ' efface
J'aimerais le voir tenter quelque-chose ainsi, par lui-même, d'abord
Randomize toto = Int((35 * Rnd)) If toto > 9 Then toto = toto + 7 toto = toto + 48
toto = Chr(toto + 48)
Randomize toto = Int((35 * Rnd)) If toto > 9 Then toto = toto + 7 msgbox Chr(toto + 48)
List1.additem Chr(toto + 48)
Dim cle As String, toto As Integer, longueur_cle As Integer, i As Integer Randomize longueur_cle = 15 For i = 1 To longueur_cle toto = Int((35 * Rnd)) If toto > 9 Then toto = toto + 7 cle = cle & Chr(toto + 48) Next MsgBox cle