错误捕捉了:)function isexists(aaa as control) as boolean
dim tmp as string
aaa=true
on error goto err1
tmp=aaa.name
exit sub
err1:
aaa=false
end function
dim tmp as string
aaa=true
on error goto err1
tmp=aaa.name
exit sub
err1:
aaa=false
end function
dim tmp as string
isexists=true
on error goto err1
tmp=aaa.name
exit sub
err1:
isexists=false
end function
MsgBox "obj 不存在"
End If
错误捕捉了:)
http://www.csdn.net/Expert/TopicView1.asp?id=574473Private Sub Command1_Click()
MsgBox DoesControlExist(Option1(1))
End Sub
Private Function DoesControlExist(ByRef ctl As Control) As Boolean
On Error GoTo handleError DoesControlExist = (ctl.Name <> vbNullString)
Exit Function
handleError:
DoesControlExist = False
End Function
Dim tmp As String
isexists = True
On Error GoTo err1
tmp = aaa.Name
Exit Function
err1:
isexists = False
End FunctionPrivate Sub Command4_Click()
MsgBox isexists(Option1(1))
End Sub还可以啊:)