Icons.Value(lvwMenu.RowTag(row)) Icons is a dictionary object and the key I am looking for may or may not exist. Why is the code below not catching the exception, the compiler keeps catching it.
[code] //Draw in the icon
Dim tmpIcon as new Picture(DefaultIconSize,DefaultIconSize)
tmpIcon = Icons.Value(lvwMenu.RowTag(row))
Return true
Exception err
if err isa KeyNotFoundException then
MsgBox “You tried to access a nonexistent item!”
end if
[/code]
For dictionary objects (or any other for that matter)… If I know a error is possible and can be trapped I handle it… and use Exception for “unexpected” errors
Dim tmpIcon as new Picture(DefaultIconSize,DefaultIconSize)
if icons.haskey(lvwMenu.Rowtag(row)) then tmpIcon = Icons.Value(lvwMenu.RowTag(row))
Return true
If “Break on Exceptions” is checked in the Project menu, the debugger appears for any exceptions, even if they are caught later. The solution is to do what Kem suggests, turn off Break on Exceptions or use the pragma to temporarily turn it off: