Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to put the list box items in textbox

listbox
1
2
3
4
5
6
7


to this...


textbox
1-2-3-4-5-6-7

its vb.net.

thank you,
Posted
Updated 7-Sep-14 19:56pm
v2

can you explain what do want to do?
 
Share this answer
 
Comments
Member 10791395 8-Sep-14 1:57am    
i want to put the list box items in textbox

listbox
1
2
3
4
5
6
7


to this...


textbox
1-2-3-4-5-6-7

its vb.net.

thank you,
You didn't provide your code.
I am writing sample code, You can achieve your requirement like this way:

txtalp.Text = "22"
Dim x As String = ""

For k As Integer = 1 To (Convert.ToInt32(textBox1.Text))
	listBox2.Items.Add(k)
Next

For i As Integer = 0 To listBox2.Items.Count - 1
	x += "-" + listBox2.Items(i)
Next
x = x.Remove(0, 1)
textBox1.Text = x
 
Share this answer
 
v3
Comments
Member 10791395 8-Sep-14 2:01am    
sir im using vb.net
Sanchayeeta 8-Sep-14 2:08am    
Please check I have updated my code to VB.Net.
Member 10791395 8-Sep-14 2:17am    
sir this is the listbox item came from.

For i As Integer = 1 To Val(textbox1)
ListBox1.Items.Add(i)
Next
Sanchayeeta 8-Sep-14 2:23am    
It doesn't matter from where ListBox value coming from, As per my understanding, you want list box value in Text box right? So you have to Iterated through all values of ListBox make a string of that and save that value in textBox,That's it.
I prided only a sample code ,If you are not getting clarity, show your listbox and textbox code I will update in that.
Member 10791395 8-Sep-14 2:37am    
wow, thank you sir. your code is right!

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