I use CallByName fuction:
if something??? then
CallByName Me, strMethodName, VbMethod,
end if
but sometimes the "strMethodName" method doesnt exist and this cause runtime error. can I examine that before calling CallByName?
Printable View
I use CallByName fuction:
if something??? then
CallByName Me, strMethodName, VbMethod,
end if
but sometimes the "strMethodName" method doesnt exist and this cause runtime error. can I examine that before calling CallByName?
VB Code:
Private Sub Form_Load() MsgBox HasProperty(Form1, "Caption") Unload Me End Sub Public Function HasProperty(objObject As Object, strProperty As String) As Boolean Dim varRet As Variant On Error Resume Next varRet = CallByName(objObject, strProperty, VbGet) If Err.Number = 0 Then HasProperty = True End If On Error GoTo 0 End Function
:)