[Func] La suite de Random. RandomString !

Partagez des fonctions et des UDF AutoIt.
Règles du forum
.
Répondre
alex1205
Niveau 5
Niveau 5
Messages : 123
Enregistré le : dim. 07 mars 2010 13:59
Status : Hors ligne

[Func] La suite de Random. RandomString !

#1

Message par alex1205 »

Après Random, RandomUnique, RandomLettre, voici [blink]RandomString[/blink] :D :D
Permettant de faire un Random en choisissant par hasard un mot d'une chaine (string).
Voici le code de la fonction:

Code : Tout sélectionner

Func RandomString($sString)
$sSplit = StringSplit($sString, "|")
$sUBound=UBound($sSplit)
$sRandom = Random(1, $sUBound,1)
For $sReturn = 1 to $sUBound step +1
If $sRandom = $sReturn Then
Return $sSplit[$sReturn]
EndIf
Next
EndFunc ;==>RandomString
 

Et l'exemple:

Code : Tout sélectionner

Msgbox(0, "RandomString", "RandomString a choisi:"&@CRLF&RandomString("Random|RandomUnique|RandomLettre|RandomString")&"Entre Random|RandomUnique|RandomLettre|RandomString")
Le "je ne sais pas" et "j'y arrive pas" n'existe dans mon vocabulaire. Toutes Questions ont une réponse, cherchez et vous la trouverai. Utilisez Recherche du forum et vous verrez. Si [blink]Aucune[/blink] question ne tient à votre problème, créez un sujet.
Répondre