# Listbox.selected

**URL:** <https://forum.xojo.com/t/listbox-selected/61555>\
**Category:** Getting Started\
**Created:** [March 2, 2021, 6:37am UTC](https://forum.xojo.com/t/listbox-selected/61555 "2021-03-02T06:37:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arief\_Sarjono](https://forum.xojo.com/user_avatar/forum.xojo.com/arief_sarjono/32/692_2.png) [@Arief\_Sarjono](https://forum.xojo.com/u/Arief_Sarjono)\
**Post date:** [March 2, 2021, 6:37am UTC](https://forum.xojo.com/t/listbox-selected/61555/1 "2021-03-02T06:37:37Z")

</div>

Hi,  
I have a listbox and some rows on it.  
is there any ways how to find out if the user select more than a row in a multiselect listbox.

thanks  
arief

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [March 2, 2021, 6:41am UTC](https://forum.xojo.com/t/listbox-selected/61555/2 "2021-03-02T06:41:23Z")

</div>

[ListBox.Selected - Xojo Documentation](https://documentation.xojo.com/api/deprecated/listbox.html#listbox-selected)

See **Getting the list of selected rows**

```auto
Var selectedRows() As Integer // Will hold the index of each selected row

For row As Integer = 0 To ListBox1.LastRowIndex
  If ListBox1.Selected(row) Then
    selectedRows.AddRow(row) // This row is selected
  End If
Next

```

---

<div class="post-metadata">

**Author:** ![Arief\_Sarjono](https://forum.xojo.com/user_avatar/forum.xojo.com/arief_sarjono/32/692_2.png) [@Arief\_Sarjono](https://forum.xojo.com/u/Arief_Sarjono)\
**Post date:** [March 2, 2021, 6:46am UTC](https://forum.xojo.com/t/listbox-selected/61555/3 "2021-03-02T06:46:48Z")

</div>

Hi,

Will it work in older version of xojo ?  
I am still using 2018r4.

thanks  
arief

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [March 2, 2021, 6:49am UTC](https://forum.xojo.com/t/listbox-selected/61555/4 "2021-03-02T06:49:34Z")

</div>

If you use the in built language reference (edit\>options\>use built-in documentation) then you can search your local documentation for the same page(listbox.selected) which will include the correct edition of the code for the version of xojo you’re using, so you’ll need:

```auto
Dim selectedRows() As Integer // Will hold the index of each selected row

For row As Integer = 0 To ListBox1.ListCount - 1 // Rows are zero-based
  If ListBox1.Selected(row) Then
    selectedRows.Append(row) // This row is selected
  End If
Next

```

---

<div class="post-metadata">

**Author:** ![Arief\_Sarjono](https://forum.xojo.com/user_avatar/forum.xojo.com/arief_sarjono/32/692_2.png) [@Arief\_Sarjono](https://forum.xojo.com/u/Arief_Sarjono)\
**Post date:** [March 2, 2021, 9:44am UTC](https://forum.xojo.com/t/listbox-selected/61555/5 "2021-03-02T09:44:06Z")

</div>

I want to explain my goals,

I have a listbox with some rows, I want to change the value of the listbox while the user is selecting more than a row.  
here is the code,

```
    dim o as integer
    for o = 0 to listbox1.liscount-1

    if listbox1.selected(o) then 'select more rows by pressing Ctrl button
    label1.text="user select multi rows"
    'replace the value of listbox
    else
    label1.text="user select 1 row only"
    'do nothing
    end if

```

thanks  
arief

---

<div class="post-metadata">

**Author:** ![anon20074439](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@anon20074439](https://forum.xojo.com/u/anon20074439)\
**Post date:** [March 2, 2021, 9:46am UTC](https://forum.xojo.com/t/listbox-selected/61555/6 "2021-03-02T09:46:29Z")

</div>

You want to change the values of multiple rows all at the same time, the multiple rows that are currently selected?

---

<div class="post-metadata">

**Author:** ![Emile\_Schwarz](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/90ced4/32.png) [@Emile\_Schwarz](https://forum.xojo.com/u/Emile_Schwarz)\
**Post date:** [March 2, 2021, 10:28am UTC](https://forum.xojo.com/t/listbox-selected/61555/7 "2021-03-02T10:28:45Z")

</div>

Do you want to compute the values found in the selected Rows and put the result into another Cell ?

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [March 2, 2021, 10:37am UTC](https://forum.xojo.com/t/listbox-selected/61555/8 "2021-03-02T10:37:38Z")

</div>

**Listbox.selcount** will tell you how many rows are selected.

---

<div class="post-metadata">

**Author:** ![Arief\_Sarjono](https://forum.xojo.com/user_avatar/forum.xojo.com/arief_sarjono/32/692_2.png) [@Arief\_Sarjono](https://forum.xojo.com/u/Arief_Sarjono)\
**Post date:** [March 2, 2021, 3:00pm UTC](https://forum.xojo.com/t/listbox-selected/61555/9 "2021-03-02T15:00:17Z")

</div>

thanks, this is the one.

regards,  
Arief
