Click here to Skip to main content
16,006,768 members

Comments by Member 11401758 (Top 1 by date)

Member 11401758 4-Jun-15 22:43pm View    
please, can someone help me out with the following lines of codes that throws: System.NullReferenceException: Object reference not set to an instance of an object.


Public Sub createGrid_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles createGrid.Click

Dim watershedLayer As MapWindow.Interfaces.Layer
Dim watershedLayerHandle As Integer = Utilities.GetWatershedLayerHandle()
' If Not (watershedLayer Is Nothing) Then
If mw.Layers.IsValidHandle(watershedLayerHandle) Then
watershedLayer = mw.Layers.Item(watershedLayerHandle)
Else
If (findWatershedShapefile.ShowDialog = Windows.Forms.DialogResult.Cancel) Then Exit Sub
UpdateWatershedPath(findWatershedShapefile.FileName)
Dim layerName As String = "Watershed (" + System.IO.Path.GetFileName(WatershedShapePath) + ")"
watershedLayer = mw.Layers.Add(WatershedShapePath, layerName)
'watershedLayer.Name = layerName
End If
'End If
' Since this is "Create" grid it uses Nothing as the Grid layer so that GridForm will create one from scratch.
gridForm = New MWAGNPSLib.GridForm(mw, watershedLayer, Nothing)
gridForm.Show()
End Sub