View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
kalle kalle is offline
external usenet poster
 
Posts: 6
Default 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
  
- Dölj citerad text -

- 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