Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,087 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,764 people online right now. Registration is fast and FREE... Join Now!




retrieve data from listbox

2 Pages V  1 2 >  
Reply to this topicStart new topic

retrieve data from listbox, visual basic express

shazron
2 Jun, 2008 - 09:35 AM
Post #1

New D.I.C Head
*

Joined: 28 May, 2008
Posts: 5

hey
i am trying to retrieve data from my sorted listbox and put it into a label...any ideas
vb
listbox1 = data
listbox2 = sorted data
this is how i have sorted data into listbox2
Dim list As New ListBox.SelectedObjectCollection(ListBox1)
Dim strItem As String
For Each strItem In ArrayList.Adapter(list).ToArray
If ListBox2.Items.IndexOf(strItem) > -1 Then
MessageBox.Show("You have already selected that paragraph")
ListBox2.Items.RemoveAt(ListBox1.Items.IndexOf(strItem))
ListBox2.SelectedItems.IndexOf(strItem)
End If
Next
ListBox2.Items.AddRange(ArrayList.Adapter(list).ToArray)
'adds selected item to listbox2


thanx
User is offlineProfile CardPM
+Quote Post

mensahero
RE: Retrieve Data From Listbox
2 Jun, 2008 - 10:05 AM
Post #2

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions

Hello.. sorry but you posted in the wrong forum.. this if for the classic vb6..

but this may give you an IDEA..

on the listbox click event add a code that somewhat looks like this..

label1.caption = listbox.text

thats not the actual code.. its just an idea..
User is offlineProfile CardPM
+Quote Post

shazron
RE: Retrieve Data From Listbox
2 Jun, 2008 - 10:32 AM
Post #3

New D.I.C Head
*

Joined: 28 May, 2008
Posts: 5

hey
i am trying to retrieve data from my sorted listbox and put it into a label...any ideas


listbox1 = data
listbox2 = sorted data
this is how i have sorted data into listbox2

vb

Dim list As New ListBox.SelectedObjectCollection(ListBox1)
Dim strItem As String
For Each strItem In ArrayList.Adapter(list).ToArray
If ListBox2.Items.IndexOf(strItem) > -1 Then
MessageBox.Show("You have already selected that paragraph")
ListBox2.Items.RemoveAt(ListBox1.Items.IndexOf(strItem))
ListBox2.SelectedItems.IndexOf(strItem)
End If
Next
ListBox2.Items.AddRange(ArrayList.Adapter(list).ToArray)
'adds selected item to listbox2

thanx

This post has been edited by PsychoCoder: 2 Jun, 2008 - 11:33 AM
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Retrieve Data From Listbox
3 Jun, 2008 - 02:10 AM
Post #4

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 4,032



Thanked: 38 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
If you want to access each element in the sorted list one-by-one, use this snippet:
vb
For Each item As String In Listbox1.Items
MsgBox(l) ' Just an example
' Add your code to insert each item into your label
Next

User is offlineProfile CardPM
+Quote Post

RodgerB
RE: Retrieve Data From Listbox
3 Jun, 2008 - 02:13 AM
Post #5

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,166



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
QUOTE(mensahero @ 3 Jun, 2008 - 04:05 AM) *

Hello.. sorry but you posted in the wrong forum.. this if for the classic vb6..


It has clearly been coded in .NET; it is in the correct section. smile.gif

This post has been edited by RodgerB: 3 Jun, 2008 - 02:13 AM
User is offlineProfile CardPM
+Quote Post

mensahero
RE: Retrieve Data From Listbox
3 Jun, 2008 - 02:20 AM
Post #6

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
QUOTE(RodgerB @ 3 Jun, 2008 - 03:13 AM) *

QUOTE(mensahero @ 3 Jun, 2008 - 04:05 AM) *

Hello.. sorry but you posted in the wrong forum.. this if for the classic vb6..


It has clearly been coded in .NET; it is in the correct section. smile.gif


I don't get it?.. if this it the right forum why is there a vb.net forum anyway? blink.gif

This post has been edited by mensahero: 3 Jun, 2008 - 02:29 AM
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Retrieve Data From Listbox
3 Jun, 2008 - 02:31 AM
Post #7

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 4,032



Thanked: 38 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
lol, Rodger must be drunk.
The code is written in VB.NET and is in the wrong forum.

I don't have MOD rights in VB.NET forum so I can't move it.
I'll ask someone to do it.
User is offlineProfile CardPM
+Quote Post

RodgerB
RE: Retrieve Data From Listbox
3 Jun, 2008 - 02:57 AM
Post #8

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,166



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
Lol. I'm an idiot. Sorry for the confusion. smile.gif

High five?
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Retrieve Data From Listbox
3 Jun, 2008 - 03:55 AM
Post #9

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 4,032



Thanked: 38 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
Thanks for moving it man.
User is offlineProfile CardPM
+Quote Post

RodgerB
RE: Retrieve Data From Listbox
3 Jun, 2008 - 03:59 AM
Post #10

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,166



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
QUOTE(born2c0de @ 3 Jun, 2008 - 09:55 PM) *

Thanks for moving it man.


LOL now you are drunk. It was already moved. That's why I felt like a drunk. I don't has mod privs.

biggrin.gif
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Retrieve Data From Listbox
3 Jun, 2008 - 04:53 AM
Post #11

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
I apologize, but I'm truly not understanding what you're asking?
User is offlineProfile CardPM
+Quote Post

shazron
RE: Retrieve Data From Listbox
3 Jun, 2008 - 05:04 AM
Post #12

New D.I.C Head
*

Joined: 28 May, 2008
Posts: 5

QUOTE(PsychoCoder @ 3 Jun, 2008 - 05:53 AM) *

I apologize, but I'm truly not understanding what you're asking?

i am trying to get the selected items from listbox2 into a label or textbox on another form

User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 11:54PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month