Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a string as example "L2 022" (ignore the double quote). How to split a string of space? So if I split into and array of arrStr(1), the value will be:

arrStr(0) = L2
arrStr(1) = 022

I don't put a delimiter on database. How can I do this?
Posted

I suggest you start here:

Microsoft MSDN - Sting.Split[^]

This should give you all the information you need to split a string.
 
Share this answer
 
Comments
Marcin Kozub 17-Mar-14 5:41am    
+5 for link
Try:
VB
Dim str As String = "L2 022"
Dim arrStr() As String = str.Split(" ")
 
Share this answer
 
Comments
Luiey Ichigo 18-Mar-14 4:08am    
I also do this and it works :)

arrStr = str.Split()
OriginalGriff 18-Mar-14 5:45am    
It is a better idea to specify the split characters: it makes it a lot clearer if next time you want to split "L2-022" instead - which won't split using the default method. It's hardly any extra typing, and it means it's clearer when you read it later.
VB
Dim str as String = "L2 022"
Dim arrStr() As String = str.Split(New [Char]() {" "c})


See String.Split Method (Char())[^].
 
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