I get
error 438 : Object does not support this property or method
when trying to run the following code. Could you help me with that please?
My macro code :
Sub test()
Dim upList As New ListRoot
upList.msg 'this one works fine
Dim g As New Gradient
upList.AppendRoot g 'line that raises the issue
End Sub
My module class code :
Public Sub AppendRoot(grad As Gradient)
If IsEmpty(content.content) Then
Set content.content = grad
Else
content.Append (grad)
End If
End Sub
Public Sub msg()
MsgBox "HEY"
End Sub
I have already tried different calls of my method:
upList.AppendRoot(g)
Call upList.AppendRoot(g)
and the one that is quoted above. None works.
Note that calling a sub/function without returning a value must be called without parenthesis:
If the function returns some value then parenthesis must be added
But if you add parenthesis to a sub/function that does not return any value like you did
… that forces the variable
grad
to be submittedByVal
whileByRef
is the standard method to submit them. So by adding parenthesis here you change fromByRef
toByVal
(you can also see that there is a space between the function/sub name and the parenthesis).Example:
Some examples to call this function:
While with 3 parameters it will throw an error if you add parenthesis where they should not be, it will be more difficult with only one parameter: