Help!

listbox double click which item

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions RSS
Next:  Look Around Today at Online Personals Date for Fr..  
Author Message
mp
External


Since: May 11, 2010
Posts: 6



PostPosted: Sat Jan 01, 2011 7:55 pm    Post subject: listbox double click which item
Archived from groups: microsoft>public>excel (more info?)

I want to know which item in a listbox was double clicked on.
This works but doesn't seem like i should have to do it this way

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim index As Integer

With ListBox1
For index = 0 To .ListCount - 1
If .Selected(index) Then
MsgBox index
End If
Next
End With

End Sub

thanks for any tips
mark
Back to top
Jim Cone
External


Since: Feb 20, 2010
Posts: 22



PostPosted: Sat Jan 01, 2011 7:55 pm    Post subject: Re: listbox double click which item [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

What you are looking for is the ListIndex...

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim Ndex As Long
Ndex = ListBox1.ListIndex
MsgBox Ndex
End Sub

Also, don't use index as a variable, Excel already uses it.
'---
Jim Cone
Portland, Oregon USA
http://www.contextures.com/excel-sort-addin.html
(30 different ways to sort in excel)



"mp"
wrote in message

>I want to know which item in a listbox was double clicked on.
> This works but doesn't seem like i should have to do it this way
>
> Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
> Dim index As Integer
>
> With ListBox1
> For index = 0 To .ListCount - 1
> If .Selected(index) Then
> MsgBox index
> End If
> Next
> End With
>
> End Sub
>
> thanks for any tips
> mark
Back to top
mp
External


Since: May 11, 2010
Posts: 6



PostPosted: Sat Jan 01, 2011 9:01 pm    Post subject: Re: listbox double click which item [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks

"Jim Cone" wrote in message

> What you are looking for is the ListIndex...
>
> Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
> Dim Ndex As Long
> Ndex = ListBox1.ListIndex
> MsgBox Ndex
> End Sub
>
> Also, don't use index as a variable, Excel already uses it.
> '---
> Jim Cone
> Portland, Oregon USA
> http://www.contextures.com/excel-sort-addin.html
> (30 different ways to sort in excel)
>
>
>
> "mp"
> wrote in message
>
>>I want to know which item in a listbox was double clicked on.
>> This works but doesn't seem like i should have to do it this way
>>
>> Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
>> Dim index As Integer
>>
>> With ListBox1
>> For index = 0 To .ListCount - 1
>> If .Selected(index) Then
>> MsgBox index
>> End If
>> Next
>> End With
>>
>> End Sub
>>
>> thanks for any tips
>> mark
>
>
Back to top
CellShocked
External


Since: Oct 22, 2009
Posts: 17



PostPosted: Sat Jan 01, 2011 11:47 pm    Post subject: Re: listbox double click which item [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Sat, 1 Jan 2011 14:55:20 -0600, "mp" wrote:

>I want to know which item in a listbox was double clicked on.
>This works but doesn't seem like i should have to do it this way
>
>Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
>Dim index As Integer
>
>With ListBox1
> For index = 0 To .ListCount - 1
> If .Selected(index) Then
> MsgBox index
> End If
> Next
>End With
>
>End Sub
>
>thanks for any tips
>mark
>
>

Listboxes are SINGLE click to SELECT. Unles you put up a hard picker
menu and assign hyperlinks or the like to each cell. Even then, it is
SINGLE click.
Back to top
mp
External


Since: May 11, 2010
Posts: 6



PostPosted: Sun Jan 02, 2011 1:08 pm    Post subject: Re: listbox double click which item [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"CellShocked" wrote
in message
> On Sat, 1 Jan 2011 14:55:20 -0600, "mp" wrote:
>
>>I want to know which item in a listbox was double clicked on.
>>This works but doesn't seem like i should have to do it this way
>>
>>Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
>>Dim index As Integer
>>
>>With ListBox1
>> For index = 0 To .ListCount - 1
>> If .Selected(index) Then
>> MsgBox index
>> End If
>> Next
>>End With
>>
>>End Sub
>>
>>thanks for any tips
>>mark
>>
>>
>
> Listboxes are SINGLE click to SELECT. Unles you put up a hard picker
> menu and assign hyperlinks or the like to each cell. Even then, it is
> SINGLE click.

Thanks for your response. I'm not sure what your point is though.
I know I can select an item with a single click. I was just looking for
how to get at the item on which the user double clicks
(which also selects that item - as well as raising the dblclick event)
as Jim pointed out it was ListIndex i was forgetting.
Thanks
Mark
ps...cute nyme Smile
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum