error during listbox drawitem event

i've got a listbox that is set to ownerdrawfixed and multiselect.

in the drawitem event i check if the index of the item being drawn is the selected index or if the index of the item is in the selectedindices collection. when i run the code and the selection changes in the list i get an error in the code.

Ife.Index = -1ThenExitSub

IfMe.lst.SelectedIndex =e.IndexThen'error occurs here

ElseIfMe.lst.SelectedIndices.Contains(e.Index)Then'error only occurs if this line exists

Else

EndIf

why do i get an error because of a line further down in my code when it hasn't yet reached that line. if i remove that line there is no problem.

can someone please explain why this error occurs

[1805 byte] By [amoeba] at [2008-1-10]