show the number of items selected in a list box ?

siamandm
BronzeLounger
Posts: 1266
Joined: 01 May 2016, 09:58

show the number of items selected in a list box ?

Post by siamandm »

Hi
if i have a list box , i would like to show a dynamic label showing the number of the item is selected

regards

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: show the number of items selected in a list box ?

Post by HansV »

Add the following to the After Update event procedure of the list box:

Code: Select all

    Me.SomeLabel.Caption = Me.SomeListBox.ItemsSelected.Count
where SomeLabel is the name of the label and SomeListBox is the name of the list box.
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1266
Joined: 01 May 2016, 09:58

Re: show the number of items selected in a list box ?

Post by siamandm »

thank you Hans,
if the lstbox is has some item selected on load the form , how to count this too please?

regards

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: show the number of items selected in a list box ?

Post by HansV »

Use the same line in the On Load event of the form.
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1266
Joined: 01 May 2016, 09:58

Re: show the number of items selected in a list box ?

Post by siamandm »

ok thank you