Instead of selecting the entire drawing and then iterating over the objects I'd recommend using a selection filter to only select the items on the layer(s) that you wish to delete.
Private Sub EraseObjectsFromLayer()
Dim DB As AcDb.Database = AcDb.HostApplicationServices.WorkingDatabase
Dim ED As AcEd.Editor = AcadApp.DocumentManager.MdiActiveDocument.Editor
Dim myT As AcDb.Transaction = DB.TransactionManager.StartTransaction
Try
Dim Values() As AcDb.TypedValue = {New AcDb.TypedValue(AcDb.DxfCode.LayerName, "Centerlines")}
Dim SF As New AcEd.SelectionFilter(Values)
Dim Result As AcEd.PromptSelectionResult = ED.SelectAll(SF)
If Result.Status <> AcEd.PromptStatus.OK Then Return
Dim IDArray As AcDb.ObjectId() = Result.Value.GetObjectIds
For Each ID As AcDb.ObjectId In IDArray
Dim Entity As AcDb.Entity = myT.GetObject(ID, AcDb.OpenMode.ForWrite)
Entity.Erase()
Entity.Dispose()
Next
myT.Commit()
Catch ex As Exception
AcadApp.ShowAlertDialog(ex.ToString)
Finally
myT.Dispose()
DB.Dispose()
End Try
End Sub
Ronnie Wilkins, Jr.