Search code examples
stringsplitchars

how to split a string or make chars in vb 2010


I searched but nothing explains how to do this, for example

Dim sentence as String = "cat is an animal"

if i make a msgbox :

MsgBox(sentence)

it shows

cat is an animal

how to make a msgbox that says

cat
is
an
animal.

Solution

  • Easy way Replace space with new line

    as in string words = MyString.Replace(" ","\r\n")

    Split would be split on space in to an array , and then join that back up with new lines which is pointless unless you need the array for something else.