473,324 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,324 developers and data experts.

Retrieve Values from a Multi-Select ListBox

MMcCarthy
14,534 Expert Mod 8TB
This is an example of code that uses a multi-select ListBox control. This is an area that seems to cause confusion and difficulty for many of our members.
Expand|Select|Wrap|Line Numbers
  1. Dim valSelect As Variant
  2. Dim strValue As String ' just used for the demonstration
  3.  
  4.     For Each valSelect In Me.listboxName.ItemsSelected
  5.         strValue = strValue & "'" & Me.listboxName.ItemData(valSelect) & "', "
  6.     Next valSelect
  7.  
  8.     ' to remove trailing comma
  9.     strValue = Left(strValue, Len(strValue)-2)
Jan 18 '07 #1
1 41481
TheSmileyCoder
2,322 Expert Mod 2GB
I just wanted to expand on this, and show how to get the value of a secondary column in a multiselect listbox:
Expand|Select|Wrap|Line Numbers
  1.    Dim v As Variant
  2.    For Each v In Me.ListBoxControl.ItemsSelected
  3.       Debug.Print Me.ListBoxControl.ItemData(v) & " - " & Me.ListBoxControl.Column(1, v)
  4.    Next
Where 1 is used to indicate I want the second column (Since the column count is 0 based)
Feb 3 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: HairlipDog58 | last post by:
I have a component that implements a property called obj of type object. The intent is that a user can pass in any value or array of values and I will be able to retrieve the values. If the...
0
by: Mark | last post by:
Hi, I have a datalist that contains a textbox as well as a dropdown list. For each single row in the datalist the associated dropdown list can have at least one value What I would like to be...
2
by: Uncle_Albert | last post by:
Hi peeps, Here's a screenshot of a particular form in my program. http://www.jdr.dsl.pipex.com/dg1.JPG Basically, when I click on 'Refresh Totals', I want it to retrieve all values from the...
0
by: Manesh | last post by:
I have an oracle function which return an oracle user defined table type. How to retrieve values from this type (function from a vb.net application ? Here is my sample code Please help create or...
5
by: gbattine | last post by:
Hi guys, i've a very important question for you,i'm stopped my work from 10 days to solve it,but nothing.... i hope your can help me. I'm developing a jsf application and i've created a datatable...
7
gchq
by: gchq | last post by:
Hi there Here is the situation - a table is built dynamically with values in the cells I need to retrieve and enter into a database. I have found a way of getting values using JavaScript, but of...
4
by: xzzy | last post by:
I have hit a wall with not being able to enumerate the items collection in a table row. given: <table runat=server id=table1> <tr> <td id=AAA>HowToReferenceThisValue</td> etc...
7
by: pushpinderbagga | last post by:
hi .. I am using a text area to feed in values to mysql .. but its not storing all the line breaks the text comes concatenated even when I feed it about 40 lines... it shows all in one line ......
3
by: sudhashekhar30 | last post by:
i have to retrieve all columns of four table except common field(which is primary key in 1 table and foreign key in other table) will come only once from main table where condition is given by user....
1
by: terminul | last post by:
Hi I have a datalist which loops through the categories and within the datalist I have a CheckBoxList which are bound on the DataList's OnItemDataBound. The only problem I have is retrieving...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.