Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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
  #5   Report Post  
Posted to microsoft.public.excel.programming
Junior Member
 
Posts: 11
Default 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
 
- 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


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-select listbox - mousedown event Greg Lovern Excel Programming 2 April 11th 11 01:39 AM
Event change listbox ranswrt Excel Programming 1 July 14th 08 11:40 PM
Listobject selected and Deselected event Kaja Excel Programming 0 October 29th 07 09:50 PM
Select Multi in Listbox - Event Click not working François Excel Programming 0 March 30th 06 07:56 PM
Selected cells become deselected? Bob Holmes Excel Programming 3 June 23rd 04 10:59 PM


All times are GMT +1. The time now is 07:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"