Any idea how to scramble?

  1. 3 months ago

    Hi,
    Need a starting direction.
    How do I take a textfield sentence like "I enjoy programming with xojo!" and scramble it up into something like "programming I xojo! enjoy with"?

    Thanks

    Clues:
    load textfield into a string
    use the String Split method to split the string using the spaces as the split delimiter. Now you have an array of words
    Use Shuffle to randomly re-arrange the array
    Now read the array back into a new string, adding a space between each.

  2. Rob L

    Jul 11 Answer
    Edited 3 months ago

    Clues:
    load textfield into a string
    use the String Split method to split the string using the spaces as the split delimiter. Now you have an array of words
    Use Shuffle to randomly re-arrange the array
    Now read the array back into a new string, adding a space between each.

  3. Got it! Thanks.

  4. Just in case anyone who needs it.

    Dim txtArray(-1) As String
    Dim count As Integer
    Dim s as String

    s = TextField1.Text
    count = CountFields(s," ")
    txtArray = s.Split(" ")
    txtArray.Shuffle

    Dim ScrambledText as string = Join(txtArray, " ")

    Textfield2.text = ScrambledText

or Sign Up to reply!