displaying delimited text

R

Ron

How do I display delimited text on multiple lines in a listbox?

For example in my textbox I have this:
Joe Doe,123 Street,Mytown

and In a listbox then I want to display:
Joe Doe
123 Street
Mytown

How would I step through that string and seperate the words by the
comma?
 
T

Tom Shelton

How do I display delimited text on multiple lines in a listbox?

For example in my textbox I have this:
Joe Doe,123 Street,Mytown

and In a listbox then I want to display:
Joe Doe
123 Street
Mytown

How would I step through that string and seperate the words by the
comma?

Cation - air code follows:
listbox1.items.addrange(delimited.Split(",".ToCharArray()))
 
H

Herfried K. Wagner [MVP]

Tom Shelton said:
Cation - air code follows:
listbox1.items.addrange(delimited.Split(",".ToCharArray()))

.... => 'delimited.Split(","c)'.
 
R

Ron

so if my textbox is named textbox1 and my listbox is named
ltsdisplay, for the button that would make this all happen I would
just need to:

lstdisplay.items.textbox1(delimited.Split(",".ToCharArray()))

is that right? or no? I try this and I get an error...
 
O

\(O\)enone

Ron said:
so if my textbox is named textbox1 and my listbox is named
ltsdisplay, for the button that would make this all happen I would
just need to:

lstdisplay.items.textbox1(delimited.Split(",".ToCharArray()))

is that right?

Not quite.

"delimited" in the samples you've been given is the delimited string, which
in your case is "Textbox1.Text" (that's where the system gets the delimited
string from).

And also the code is more concise using Herfried's suggestion of how to
provide a character variable containing a comma.

Try this:

\\\
lstDisplay.Items.AddRange(Textbox1.Text.Split(","c))
///
 

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

Top