I don't know how to do it in VB.net but instead of DirectCast is there something similar to 'as' in C#??
e.g. in C# you would get an object from the transaction using something like:
Polyline poly = tr.GetObject(objectId, OpenMode.ForWrite) as Polyline;
The direct cast way in C# would be:
Polyline poly = (Polyline)tr.GetObject(objectId, OpenMode.ForWrite);
The diffference is, 'as' returns null on error whereas the other would cause an exception so with 'as' all you need to do is check if the returned object is null:
if(poly == null){
continue; // skip it, it isn't any good anyway.
}
hope that makes sense