• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 182
  • Last Modified:

How to call a subroutine located in a different form

How can I call a subroutine that in a totally different form?
  • 2
1 Solution
Éric MoreauSenior .Net ConsultantCommented:
the subroutine needs to be public and you call it this way:

In the form which has the subroutine you want to call ensure that the subroutine is Public.  

Public Hello()
  MsgBox "Hello World"
End Sub

For sake of arguement also call this form "FormWithRoutine"

In the form you are calling from type the name of the Form with the subroutine, type a period, and the specify the name of the Routine you which to call.  In the example given above it would be:

Éric MoreauSenior .Net ConsultantCommented:
another newbie!!!

carlosferreira, your post is not an answer. You can read at the bottom of this screen :
An answer is a specific solution to a question and should be submitted if it will solve the questioner's problem and doesn't duplicate a previous comment. "

Also, you made a mistake. It should be read: Public SUB Hello()
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now