How to split for example this string
12.2.2009,21.2.2009,20.9.2019
So, coma (,) is most important.
So, I want to fill listbox with this strings, and split between comas.
12.2.2009
21.2.2009
20.9.2019
The number of string is not definite.
Thanks!
Printable View
How to split for example this string
12.2.2009,21.2.2009,20.9.2019
So, coma (,) is most important.
So, I want to fill listbox with this strings, and split between comas.
12.2.2009
21.2.2009
20.9.2019
The number of string is not definite.
Thanks!
vb.net Code:
Dim source As String = "12.2.2009,21.2.2009,20.9.2019" Dim tokens() As String = source.Split(","c) For Each token As String In tokens Debug.WriteLine(token) Next
I don't understand your code very well. Where is listbox in the whole story?
cicatrix's code is about as basic as it gets. When you use "Split()", it returns an array of strings; in the example's case "tokens()". If that last sentence confuses you, then check out MSDN for help on the basics of arrays. They're one of the oldest and most used structures in programming.
in the cicatrix code replace
withCode:For Each token As String In tokens
Debug.WriteLine(token)
Next
Code:ListBox1.Items.AddRange(tokens)