Weird listbox behaviour

After filling a listbox with a list of items to be selected. The program then waits for the cellclick event before responding. Upon receiving a cell click, the code does not respond as expected. I placed a message box to monitor what the cellclick event was producing i.e.:

msgbox LB1.text

All I get for the first click on a specific cell is a blank string. It takes a second click for the listbox to produce the desired results. Am I missing something??

The .text property will give you the currently selected row. Apparently, the cellClick event is firing before the row is selected. Try

MsgBox me.List( row )

and see what you get.

Fixed! Many thanks.

CellClick fires before the row is selected because CellClick tells the listbox what row to select!

Because the user can change the selection by other means (arrow keys) you’re going to want to put your code in the Change event instead of CellClick.

but not in the Web-Edition :frowning: :smiley: