Link to home
Start Free TrialLog in
Avatar of hpp123
hpp123

asked on

Get First Selected Item In A Listbox

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!
Avatar of rockiroads
rockiroads
Flag of United States of America image

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

ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hpp123
hpp123

ASKER

That did the trick! Thank you!!!
no probs

note sVal is set to nothing if no selections made