Question: Splitting A String

  • Thread starter Thread starter VB Programmer
  • Start date Start date
V

VB Programmer

I have a string, which can have one or more elements, seperated by a "##"
delimiter. Here's some examples:

One
One##Two##Three
One##Two##Three##Four##Five

How can I take the string and fill a LISTBOX based on each item?

I know Split can split the strings, but how do I know how many "items"
exist, etc...?

Or you might know a better way....
 
If I understand what you're asking, then the following code might help:

Dim TestString As String
TestString = "test1##test2##test3"
Me.ListBox1.DataSource = Split(TestString, "##")
Me.ListBox1.DataBind()

You don't need to know how many items there are in the string in order to
bind to a list box, but if you want to know, you could use:
Me.ListBox1.Items.Count
or
Split(TestString, "##").Length
 
Thanks!
Kim Quigley said:
If I understand what you're asking, then the following code might help:

Dim TestString As String
TestString = "test1##test2##test3"
Me.ListBox1.DataSource = Split(TestString, "##")
Me.ListBox1.DataBind()

You don't need to know how many items there are in the string in order to
bind to a list box, but if you want to know, you could use:
Me.ListBox1.Items.Count
or
Split(TestString, "##").Length
 
Back
Top