Calling a module function from a class method

  • Thread starter Thread starter ranafout
  • Start date Start date
R

ranafout

Hello,

I would like to know if it is possible to call a function that has bee
defined in simple module from a method of a class (just as stati
function).

I tried to do it, but I have an error message 424 "Object required
meaning probably that a object.method syntax was expecting.

I tried also to call the function with module_name.function() but i
failed...

Thanks,

Vinc
 
You should be able to call a public function in standard module from
within a class (but I'd advise against it...) For example:

This in a class module named Class1:

Private Sub Class_Initialize()
MyFunction
End Sub

This in a standard module:

Public Sub Test()
Dim c As Class1
Set c = New Class1
Set c = Nothing
End Sub

Public Function MyFunction() As Boolean
MsgBox "Did it!"
End Function

Run the macro Test and see the message from the function, called from
within the class.
 
Back
Top