How to duplicate Access' listbox in VB6 
Author Message
 How to duplicate Access' listbox in VB6

In Access, I can load a recordset into a listbox.
Maybe this recordset has product no. and product description
User doesn't care about product no., just wants to see description, so I can
set column 1 to 0 width and leave column 2, the description for user to
select.
My code takes the column 1 value, the product no. as it's selection.
Example:
1234  Big Hammer
2345  Little Hammer
3456  Mini-hammer

Customer clicks Mini-hammer, but the value 3456 is passed in my code

How do I duplicate this in VB6?
Do I have to buy a special listbox control?

Thank you!
Tony



Sun, 05 Sep 2004 08:28:49 GMT  
 How to duplicate Access' listbox in VB6
Use the ItemData property of the ListBox. Each item in the list has an
associated ItemData (data type = Long). Note that List1.NewIndex always
points to the last item added to List1.

    List1.AddItem "Big Hammer"
    List1.ItemData(List1.NewIndex) = 1234
    List1.AddItem "Little Hammer"
    List1.ItemData(List1.NewIndex) = 2345
    List1.AddItem "Mini-Hammer"
    List1.ItemData(List1.NewIndex) = 3456

To find the ID for the selected item...

Dim lItemID As Long

    lItemID = List1.ItemData(List1.ListIndex)

HTH,
Rocky


Quote:
> In Access, I can load a recordset into a listbox.
> Maybe this recordset has product no. and product description
> User doesn't care about product no., just wants to see description, so I
can
> set column 1 to 0 width and leave column 2, the description for user to
> select.
> My code takes the column 1 value, the product no. as it's selection.
> Example:
> 1234  Big Hammer
> 2345  Little Hammer
> 3456  Mini-hammer

> Customer clicks Mini-hammer, but the value 3456 is passed in my code

> How do I duplicate this in VB6?
> Do I have to buy a special listbox control?

> Thank you!
> Tony



Sun, 05 Sep 2004 19:42:49 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Duplicating Access's Lookup/Row Source/SQL in VB

2. I am getting duplicate records, I mean everything is duplicate even Access record number

3. Help - Can't disconnect Access - VB6 + Access 97 + NT4.0

4. VB6 + Access 97 + NT4.0 - Can't disconnect Access

5. VB6 Equivalent of Access 97 ListBox/ComboBox?

6. How to search for duplicates in a Listbox ?

7. prevent duplicate when adding into listbox

8. Removing duplicates in listbox

9. How to check duplicates in Listbox control?

10. Duplicates in a listbox

11. How to check duplicates in Listbox control?

12. Removing duplicate items from listbox

 

 
Powered by phpBB® Forum Software