MapWindow 4 - ActiveX Control Programming : MapWindow Discussion Forum
I am trying to buffer a polyline shapefile using the MapWinGIS activeX version 4.8 through Visual Basic 6. The problem is that the following code crashes on the line below the @@@@'s: Function CreateBuffer(dblDistance As Double) As Boolean Dim lngHandle As Long
Use of BufferByDistance
Posted by:
DavidvE ()
Date: June 13, 2012 03:08PM
I am trying to buffer a polyline shapefile using the MapWinGIS activeX version 4.8 through Visual Basic 6. The problem is that the following code crashes on the line below the @@@@'s:
Function CreateBuffer(dblDistance As Double) As Boolean
Dim lngHandle As Long
Dim sf As New MapWinGIS.Shapefile
Dim sfBuffer As New MapWinGIS.Shapefile
Dim result As Variant
lngHandle = frmMain.lvLegend.SelectedItem.Tag
Set sf = frmMain.mapMain.GetObject(lngHandle)
'---create a buffer around a line
sfBuffer.DefaultDrawingOptions.LineWidth = 3#
sfBuffer.DefaultDrawingOptions.LineColor = vbBlue
'@@@crashes at following line with "Object doesn't support this property or method" error
sfBuffer = sf.BufferByDistance(dblDistance, 30, False, True)
If sfBuffer = Null Then
MsgBox "Failed to calculate buffer"
CreateBuffer = False
Exit Function
End If
If frmMain.mapMain.AddLayer(sfBuffer, True) = True Then
CreateBuffer = True
Else
CreateBuffer = False
End If
End Function
Thanks for any help.
David
Function CreateBuffer(dblDistance As Double) As Boolean
Dim lngHandle As Long
Dim sf As New MapWinGIS.Shapefile
Dim sfBuffer As New MapWinGIS.Shapefile
Dim result As Variant
lngHandle = frmMain.lvLegend.SelectedItem.Tag
Set sf = frmMain.mapMain.GetObject(lngHandle)
'---create a buffer around a line
sfBuffer.DefaultDrawingOptions.LineWidth = 3#
sfBuffer.DefaultDrawingOptions.LineColor = vbBlue
'@@@crashes at following line with "Object doesn't support this property or method" error
sfBuffer = sf.BufferByDistance(dblDistance, 30, False, True)
If sfBuffer = Null Then
MsgBox "Failed to calculate buffer"
CreateBuffer = False
Exit Function
End If
If frmMain.mapMain.AddLayer(sfBuffer, True) = True Then
CreateBuffer = True
Else
CreateBuffer = False
End If
End Function
Thanks for any help.
David
Re: Use of BufferByDistance
Posted by:
sindizzy ()
Date: June 14, 2012 05:01PM
Are you sure you have a valid handle to your shapefile sf? Try other functions on sf and see it they are valid.
AGP
AGP
Sorry, only registered users may post in this forum.


