Function Character Arrays Class

ShuffleString

Shuffle the characters within a string. Randomly rearranges the characters within the string.

Signature (Visual Basic / VBA)

Public Function ShuffleString( _
    ByVal vValue As Variant _
    ) As Variant

Code Example

    Rnd(-1) = 0.224007
    ShuffleString("12345") = "51234"
    ShuffleString("12345") = "54312"

Parameters

Parameter Description
vValue String containing the characters whose positions are to be rearranged. Function returns Null if vValue is Null or cannot be fixed up to a String.

Notes & Version History

Note This function is "volatile" because it uses the random number generator to select the new positions for each character. If you use the Visual Basic Rnd function to seed the random number generator as in the examples above, you can reproduce the same results as are shown. There is generally no need to call the Rnd function within your programs since Entisoft Tools initializes the Visual Basic random number generator once with "Randomize" statement.