gkmorales

nullreferenceexception error

Discussion created by gkmorales on Jun 8, 2011
hi,

im trying to creat a custom toolbar with tools for arcmap.

i have a combobox in it and added some codes in the ComboBox1_SelectedIndexChange() to remove all layers.

here's the code added

private sub ComboBox1_SelectedIndexChange()
removeLayers()
end sub

sub removeLayers()
Dim pMxDoc as IMxDocument = DirectCast(m_Application.Document, IMxDocument)
Dim pMap as IMap = pMxDoc.FocusMap

pMap.ClearLayers()

pMxDoc.UpdateContents()
pMxDoc.ActiveView.Refresh()
end sub

but when I start debugging to test if the code is working I get the error

NullReferenceException was unhandled bu user code
Object reference not set to an instance of an object.

can someone help me with this...

i'm using VS2008 and arcgis 9.3

Outcomes