帮忙看函数是否可以正确返回值

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)
...全文
71 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复

7,787

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧