Click here to Skip to main content
15,886,007 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to put the list box items in textbox like this

listbox
1
3
5
7
10

to this...


textbox
1-3-5-7-10

its vb.net.

thank you,
Posted
Updated 12-Sep-14 15:26pm
v2
Comments
Sergey Alexandrovich Kryukov 12-Sep-14 21:28pm    
What you want to do is not clear. Do you want to put all the items of the list box in a string, or what? First of all, if you say "ListBox" or "TextBox", the question is: what types do you mean, exactly? Full type names, please.

More importantly, what have you tried so far?

—SA
Member 10791395 12-Sep-14 23:01pm    
ALL I WANTED IS THIS, BEACOUSE IM GONNA USE IT FOR NUMBERS

listbox
1
3
5
7
10

to this...

textbox
1-3-5-7-10
Sergey Alexandrovich Kryukov 12-Sep-14 23:21pm    
Please, don't shout (ALL CAPS is considering shouting on the Web, not very polite).
No need to repeat information you already put in your question. As you don't want to tell us what have you tried so far, why should we help you solving this trivial problem? What if the complete solution cannot help you (which is quite likely)? Nobody wants to waste time.

Thank you for understanding.

—SA
Member 10791395 13-Sep-14 0:03am    
im sorrry sir, im just a new here in website,
will you help me on this sir please..
Abhinav S 12-Sep-14 23:33pm    
This is a repost.

VB
For i = 0 To ListBox1.Items.Count - 1
    textbox1.Text = textbox1.Text & "-" & ListBox1.Items(i).ToString
Next
textbox1.Text = textbox1.Text.Substring(1)<pre lang="vb">
 
Share this answer
 
Comments
Member 10791395 13-Sep-14 0:28am    
wow, thanks a lot sir,
but there still a problem
it has "-" in the first number..

it should be like this 9-2-3-1

not like this -9-2-3-1

im just new here in the web,
and im still studying vb.net,
nilesh sawardekar 16-Sep-14 13:32pm    
did you tried this...
textbox1.Text = textbox1.Text.Substring(1)
nilesh sawardekar 16-Sep-14 13:33pm    
who and why downvoted?
Use this Code , Defiantly you will get solution of your Problem..

VB
For i As Integer = 0 To ListBox1.Items.Count - 1
	TextBox1.Text = TextBox1.Text + "-" + ListBox1.Items(i).Text
Next
TextBox1.Text = TextBox1.Text.Substring(1)



Thanks
AARIF
 
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