Question: Splitting A String

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....
 
K

Kim Quigley

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
 
V

VB Programmer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top