Extracting Data from a ListBox-Newbie 
Author Message
 Extracting Data from a ListBox-Newbie

I've spent about 3 hours fiddling with this problem (time to get a better text
perhaps?) and finally decided to turn it over to the pros. I am populating a
style 0 ListBox with names from a .mdb file in the Form_Load event. Eventually
the user clicks on a choice. I would like that choice to show up later in a
msgbox. Any ideas?

Thanks,
R



Sun, 28 Jul 2002 03:00:00 GMT  
 Extracting Data from a ListBox-Newbie
Hi,

Try:

MsgBox "You selected " & lstYourListBox.Text

For a Style 0 ListBox, the Text property holds the value the
user selected.

If your using Style 2 (or 1, I think), you'll have to
reference lstYourListBox.List(0) to get the value the user
selected -- Text is read-only for these Style ListBoxes.

Of course, lstYourListBox.List(0) should work for any
Style...

Good luck -- hope this helps.

Burnie

* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful



Sun, 28 Jul 2002 03:00:00 GMT  
 Extracting Data from a ListBox-Newbie
First you need to set which line of the listbox you want . say you wanted
the 7th line from the box. use this code...

list1.listindex = 7

then extract the contents using this...

contents$ = list1.text

thats it, the contents of line 7 will be placed into the variable contents$,
list1.listcount is number of lines in the listbox.

Decipher.
Homepage: - http://www.shaun-howe.8m.com


Quote:
> I've spent about 3 hours fiddling with this problem (time to get a better
text
> perhaps?) and finally decided to turn it over to the pros. I am populating
a
> style 0 ListBox with names from a .mdb file in the Form_Load event.
Eventually
> the user clicks on a choice. I would like that choice to show up later in
a
> msgbox. Any ideas?

> Thanks,
> R



Sun, 28 Jul 2002 03:00:00 GMT  
 Extracting Data from a ListBox-Newbie
R,

One way to retrieve the highlighted item in a listbox is to use the
listbox's Text property:

    Dim myName as String

    myName = List1.Text

    Msgbox myName

Another way is to use the List and ListIndex properties.  The List property
is an array of all the items in the listbox.  The ListIndex property points
to the highlighted item in the listbox.  Example:

    Dim myName as String

    If List1.ListIndex >= 0 Then
        myName = List1.List (List1.ListIndex)
        Msgbox myName
    Else
        Msgbox "No item in the list is highlighted"
    End If

Hope this helps,

Kerry Moorman


Quote:
>I've spent about 3 hours fiddling with this problem (time to get a better
text
>perhaps?) and finally decided to turn it over to the pros. I am populating
a
>style 0 ListBox with names from a .mdb file in the Form_Load event.
Eventually
>the user clicks on a choice. I would like that choice to show up later in a
>msgbox. Any ideas?

>Thanks,
>R



Sun, 28 Jul 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Extracting data from listbox into MSFlexGrid

2. newbie:how 2 collect data from databound listbox

3. Extracting unique array entries to listbox

4. How to extract multiple records (rows) from one recordset -- now for listbox

5. extract bitmap from ownerdrawn listbox

6. Newbie: Extracting xml from .asp page into dataset

7. Newbie: Help on Extracting Recordsets

8. Newbie: Extracting a substring from a string

9. Comparing user entered data to listbox data??

10. Extracting data from a sub form

11. Extracting data from a report into a table

12. Extracting data from OLE type in a recordset

 

 
Powered by phpBB® Forum Software