Set Layer Index for Added Layer

Discussion created by davecouture on Dec 6, 2013
Using VB.NET, how can I add a Layer at a certain position in the TOC? I'm able to add a layer, but I'm having trouble changing its index. In this example, I'm trying to send the added layer at the bottom of the TOC. The part in red is where I'm having trouble.

Dim pMap As IMap = My.ArcMap.Document.ActiveView
Dim lyr As ILayerFile = New LayerFile()
Dim parcels As String = "D:\Parcels.lyr"

If System.IO.File.Exists(parcels) Then
    Dim pLayer As ILayer = lyr.Layer
    pMap.setLayerIndex(pLayer, pMap.LayerCount + 1)
    MsgBox(parcels + " cannot be found")
End If