- How to divide a string into single words
  - The Program
  - The Code:
  - The Source

# How to divide a string into single words

With Split() you can extract substrings from a string, which are separated by a separator.
You can define the separator (space by default), and you can define characters which should be ignored.
Split() creates an array with all the substrings in it.
Syntax:
`Split(myString AS String [, separator AS String, escape AS String])`

## The Program

Just type in a sentence with more than one word and click the button.
The label at the bottom shows the words the other way round.

## The Code:

    STATIC PUBLIC SUB Main()
      hForm AS Fmain
      hForm = NEW Fmain
      hForm.show
    END

    PUBLIC SUB Button1_Click()
      myAr AS Array
      myStr AS String
      outstr AS String
      x AS Integer

      outstr = ""
      myAr = Split(TextBox1.Text, " ")
      FOR x = 1 TO myAr.length
        outstr = outstr & " " & myAr[myAr.length - x]
      NEXT
      TextLabel1.Text = outstr
    END

## The Source

Download