Click here to Skip to main content
15,920,655 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hey guys,

i have a string, lets call is 'text' and i want to split it into every character but also erase the spaces. If you can't erase the spaces, i can do that my self in another code piece. lets say that 'text' is equal to 'Hello World', i wand the output code to be:

h
e
l
l
o
w
o
r
l
d
Posted

Try:
VB
Dim myString As String = "Hello World"
Dim withNoSpaces As String = myString.Replace(" ", "")
For Each c As Char In withNoSpaces
    Console.WriteLine(c)
Next
 
Share this answer
 
As an alternate, you can always use RegEx.Split. This [^] may help. In particular, look at the last example given on that link.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900