Welcome to Dream.In.Code
Click Here
Getting VB Help is Easy!

Join 118,588 VB Programmers for FREE! Ask your question and get quick answers from experts. There are 844 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



vb code

 
Reply to this topicStart new topic

vb code, application program to display the items in the listbox from the list

ramyaa
post 7 Aug, 2008 - 07:19 PM
Post #1


New D.I.C Head

*
Joined: 19 Jul, 2008
Posts: 5


My Contributions


CODE

list1.addItem "pen"
list1.addItem "pencil"
list1.addItem "scale"
list1.addItem "rubber"

i want to display the items in the listbox2 from the list1.what command should i use to display the contents in the listbox.
User is offlineProfile CardPM

Go to the top of the page


Martyr2
post 7 Aug, 2008 - 08:33 PM
Post #2


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 4,642



Thanked 121 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


If you are looking to copy the items from List1 to List2 then you can use this...

vb

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
List2.AddItem List1.List(i)
Next
End Sub


It loops through the items of List1 and copies them over to List2 when they click a command button. Hope that is what you were looking for.

Enjoy!

"At DIC we be list copying code ninjas... and when it comes to test, people copy us!" decap.gif
User is offlineProfile CardPM

Go to the top of the page

AdamSpeight2008
post 7 Aug, 2008 - 09:07 PM
Post #3


DICula

Group Icon
Joined: 29 May, 2008
Posts: 614



Thanked 38 times

Dream Kudos: 2000
My Contributions


QUOTE(Martyr2 @ 8 Aug, 2008 - 04:33 AM) *

If you are looking to copy the items from List1 to List2 then you can use this...

vb

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
List2.AddItem List1.List(i)
Next
End Sub


It loops through the items of List1 and copies them over to List2 when they click a command button. Hope that is what you were looking for.

Enjoy!

"At DIC we be list copying code ninjas... and when it comes to test, people copy us!" decap.gif

You can copy the list items in one go in VB.net.
vb

ListBox2.Items.Clear()
ListBox2.Items.AddRange(ListBox1.Items)

"At DIC we be list copying via iteration code killing ninjas masters." decap.gif ph34r.gif
User is offlineProfile CardPM

Go to the top of the page

Martyr2
post 8 Aug, 2008 - 10:55 PM
Post #4


Programming Theoretician

Group Icon
Joined: 18 Apr, 2007
Posts: 4,642



Thanked 121 times

Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions


This isn't the VB.NET forum Adam. tongue.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/11/08 07:29PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month