I have the following code in the change event of my listbox:
// SET LangSel TO THE TEXT CONTAINED IN THE SELECTED ROW
LangSel = (Me.Cell(Me.ListIndex, 0))
MsgBox ("LangSel")
I am trying to put the text content of the selected row, into the LangSel property.
Here is what happens:
When I click on test row - MsgBox = test
When I click on test2 row - MsgBox = test2
When I click on an empty row - the MsgBox displays 2 lines of text test (on the top line) followed by test2 (underneath)???
Could someone please advise me where I have gone wrong??
if me.ListIndex <> -1 then
// SET LangSel TO THE TEXT CONTAINED IN THE SELECTED ROW
LangSel = (Me.Cell(Me.ListIndex, 0))
else
LangSel = ""
end if
MsgBox (LangSel)
It was being overwritten. With the contents of the entire column. If you pass -1 to Listbox.Cell, it will give you all the values in the column or row. Listbox.Cell(-1,-1) returns the entire contents of the listbox.