帮忙看函数是否可以正确返回值
skink 2004-02-04 11:59:08 '如下的函数,是否可以正确返回我想要的值呢,为什么
Private Function CloneElement(pElem As IElement) As esriCore.IElement
On Error GoTo ErrorHandler
Dim pNewElem As IElement '
If TypeOf pElem Is ILineElement Then
Dim pNew As ILineElement
Set pNew = New LineElement
Dim pLineElem As ILineElement
Set pLineElem = pElem
pNew.symbol = pLineElem.symbol
Set pNewElem = pNew
Set pNew = Nothing
Set pLineElem = Nothing
ElseIf TypeOf pElem Is IFillShapeElement Then
Dim pFillElem As IFillShapeElement
Set pFillElem = New PolygonElement
Dim pFill As IFillShapeElement
Set pFill = pElem
pFillElem.symbol = pFill.symbol
Set pNewElem = pFillElem
Set pFillElem = Nothing
Set pFill = Nothing
ElseIf TypeOf pElem Is IMarkerElement Then
Dim pMarker As IMarkerElement
Set pMarker = New MarkerElement
Dim pMarkerElem As IMarkerElement
Set pMarkerElem = pElem
pMarker.symbol = pMarkerElem.symbol
Set pNewElem = pMarker
Set pMarker = Nothing
Set pMarkerElem = Nothing
End If
pNewElem.Geometry = pElem.Geometry
Set CloneElement = pNewElem
Exit Function
ErrorHandler:
MsgBox "系统出现错误!" & vbNewLine & " 错误代码:" & Err.Number & ": " & Err.Description & vbNewLine, vbCritical + vbOKOnly, "错误"
End Function
'使用方法
Set m_Element = CloneElement(m_OldEle)