Calling a module function from a class method

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
 
O

onedaywhen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top