Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Get First Selected Item In A Listbox

Posted on 2006-05-17
4
Medium Priority
?
248 Views
Last Modified: 2008-02-26
I have a list box. The user can select multiple lines in the list box. How do I get the row and column of the first line they select in the list box? Say they select row 3, 7, 9, 11. I need the .column(row, column) for line 3.

Any help will be greatly appreciated!
0
Comment
Question by:hpp123
  • 3
4 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 16702724
just use 0,0

dim bLoop as Boolean
dim i as integer
dim sVal as string

bLoop = True
i=0
sval = ""
do while bLoop = True

    if i > lstbox.ListCount-1 then
        bLoop = False
     elseif lstbox.selected(i) = True
        bloop = false
        sVal = lstbox.selected(i)
     end if
     i=i+1
loop

if sVal <> "" then msgbox "First item = " & sVal

0
 
LVL 65

Accepted Solution

by:
rockiroads earned 1000 total points
ID: 16702746
slight mods

forgot the then
elseif lstbox.selected(i) = True then

and to get the value
sVal = lstbox.column(i,0)           'this gets value from column 0
0
 

Author Comment

by:hpp123
ID: 16703393
That did the trick! Thank you!!!
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 16703566
no probs

note sVal is set to nothing if no selections made

0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question