How to call a sub from UserForm Module

  • Thread starter Thread starter Myles
  • Start date Start date
M

Myles

Suppose I am dwelling in a general module and want to call up
subroutine "Test" located in a Userform1 module, provided the sub i
not qualified PRIVATE, I would use *Call Userform1.Test*

Now, how do I accomplish the same task if the call is made, not from
general module, but from a ClassModule? Call Userform1.Test fails i
this connection.

Thanks for any help.


Myle
 
Hi Myles

For me it works same if called from a normal or class module

' in userform1
Sub test(x)
x = x + 2
End Sub

' in class1
Sub try()
n = 2
Call UserForm1.test(n)
MsgBox n
End Sub

' in normal module
Sub abc()
Dim c As New Class1
c.try
End Sub

Regards,
Peter T
 
Many thanks Peter for the solution. It's not as straightforward as on
would think, if because the code

Dim c As New Class1
c.try

in the general module is crucial. That is enlightening.

One again, thanks.


Myle
 

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

Back
Top