Prevent ListBox Double-Click Errors

There's a bug (Q180833) in the VBCE ListBox control that allows the Double Click event to fire when there are no items in the ListBox. Normally in VB, the Double Click event does not fire if there are no items in the ListBox. Normally, it is safe to assume that there will be a valid (greater than -1) ListIndex value of the ListBox while in the Double Click event.

To prevent application errors, you should add the following check to the DblClick event if you are going to be doing anything in the DblClick event:

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.