Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Multi listbox change event - selected or deselected
Good day Group,
Need some guidance how to determine if the click on a multi listbox is a selection or a deselection. I am building an array by the multi listbox like (in listbox change event): arJoin(UBound(arJoin)) = Me.ListBox1.Column(1, Me.ListBox1.ListIndex) If the click is a selection then OK but if it is a deselection I need to know and take care of that in some way. Grateful for some hints. Brgds CG Rosén |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Multi listbox change event - selected or deselected
hi,
Code:
Dim x As Integer Private Sub ListBox1_Change() Dim i As Integer, n As Integer For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) = True Then n = n + 1 Next i If n x Then x = x + 1 MsgBox "select" Else x = x - 1 MsgBox "deselect" End If End Sub -- isabelle Le 2011-04-23 05:02, kalle a écrit : Good day Group, Need some guidance how to determine if the click on a multi listbox is a selection or a deselection. I am building an array by the multi listbox like (in listbox change event): arJoin(UBound(arJoin)) = Me.ListBox1.Column(1, Me.ListBox1.ListIndex) If the click is a selection then OK but if it is a deselection I need to know and take care of that in some way. Grateful for some hints. Brgds CG Rosén |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Multi listbox change event - selected or deselected
I forgot to tell you that the solution given before is ok if the MultiSelect property = fmMultiSelectMulti
-- isabelle Le 2011-04-23 23:48, isabelle a écrit : hi, Code:
Dim x As Integer Private Sub ListBox1_Change() Dim i As Integer, n As Integer For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) = True Then n = n + 1 Next i If n x Then x = x + 1 MsgBox "select" Else x = x - 1 MsgBox "deselect" End If End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Multi listbox change event - selected or deselected
On 24 Apr, 06:12, isabelle wrote:
I forgot to tell you that the solution given before is ok if the MultiSelect property = fmMultiSelectMulti -- isabelle Le 2011-04-23 23:48, isabelle a écrit : hi, Code:
Dim x As Integer Code:
Private Sub ListBox1_Change() Dim i As Integer, n As Integer For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) = True Then n = n + 1 Next i If n x Then x = x + 1 MsgBox "select" Else x = x - 1 MsgBox "deselect" End If End Sub - Visa citerad text - Hi Isabelle, Thanks for your code. I have problems to figure it out. Seemes to work för the last selected item in the list but not if there are several selections and one is deselected. Is not the value for x set at all? Brgds CG Rosén |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Multi listbox change event - selected or deselected
On 04/24/2011 12:34 AM, kalle wrote:
On 24 Apr, 06:12, wrote: I forgot to tell you that the solution given before is ok if the MultiSelect property = fmMultiSelectMulti -- isabelle Le 2011-04-23 23:48, isabelle a écrit : hi, Code:
Dim x As Integer Code:
Private Sub ListBox1_Change() Dim i As Integer, n As Integer For i = 0 To ListBox1.ListCount - 1 If ListBox1.Selected(i) = True Then n = n + 1 Next i If n x Then x = x + 1 MsgBox "select" Else x = x - 1 MsgBox "deselect" End If End Sub - Visa citerad text - Hi Isabelle, Thanks for your code. I have problems to figure it out. Seemes to work för the last selected item in the list but not if there are several selections and one is deselected. Is not the value for x set at all? Brgds CG Rosén Would it work to keep the total number of selected items in a static variable, and then you just count the selected items and compare it to the previous total in each click event, then update the total to the current number? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Multi listbox change event - selected or deselected
kalle laid this down on his screen :
Hi Isabelle, Thanks for your code. I have problems to figure it out. Seemes to work för the last selected item in the list but not if there are several selections and one is deselected. Is not the value for x set at all? Brgds CG Rosén Is this the same project ("Array - delete and replace elements" posted 4/17/2011) for building strings that you said you'd work towards following my suggestions? Do you want some help with implementing my suggestion? Or do you still want to keep messing around trying to figure out how to get this approach working? -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Multi listbox change event - selected or deselected
yes you're right and then just replace the "MsgBox..." by run another code in case is "select" or "deselect"
-- isabelle Le 2011-04-24 03:52, mscir a écrit : Would it work to keep the total number of selected items in a static variable, and then you just count the selected items and compare it to the previous total in each click event, then update the total to the current number? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Multi-select listbox - mousedown event | Excel Programming | |||
Event change listbox | Excel Programming | |||
Listobject selected and Deselected event | Excel Programming | |||
Select Multi in Listbox - Event Click not working | Excel Programming | |||
Selected cells become deselected? | Excel Programming |