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")