first, i'm not really sure, but i'll give it a try:
1. dbnull() returns only info on an entity's value, default or not, nothing about the entity itself. i'm assuming the intention is to make sure the selection set is not an empty one, i.e. that something indeed has been returned by the set. an appropriate check from the outset may be the selectionset.count;
2. the code opens the selectionobjects as entity and presumes this entity to have a colour property which can be changed. even if it has, i reckon that in order to gain access to that color property the selectionobject needs to be opened as an object that has that colour property. in other words, 'entity' is too general and could be something that has no colour property, identify what the object is accuratly enough, e.g. a line, open it as a line if that's the case and then access line.colourindex. (a filter for selection might be considered in the first place, however, only to narrow the results set, selectedobjects would still need to be opened as, e.g. line.) entity actually has a colourindex property, but then again e.g. circle has an explode method where a circle cannot be exploded.
i agree with felix and add if you are calling this method from a modeless dialog or a paletteset you must lock the document.
Instead of IsDBNull you should use ObjectID.IsNull.
Start with some of our most frequented solutions to get help installing your software.