简体   繁体   中英

Listbox.Selected shows run time error '-2147024809(80070057)'

I have a listbox which is set to multi select. When I use listbox.selected to check the item selection status、I get the run time error. Run-time error '-2147024809(80070057)':Could not get selected property. Invalid argument.

There are 55 items set in the listbox. And when i=25, the error happens. What is the cause of this error?

' Add item to listbox
with me
    For i = LBound(arr) To UBound(arr)
      .ListBox1.AddItem arr(i)
    Next
End With

' Check listbox
with me
    arr = Array()
    For i = 0 To .ListBox1.ListCount - 1
      If .ListBox1.Selected(i) = False Then    <-Error happen here
        ReDim Preserve arr(UBound(arr) + 1)
        arr(UBound(arr)) = .ListBox1.List(i)
      End If
    Next
End With

The error disappeared after recreating the form and all related processing,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM