Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameters between macros

Status
Not open for further replies.

vivagupta

Technical User
May 9, 2006
7
IN
Hi there,

I am trying to find if we can pass parameters between macros. I searched postings on this forum but did not find any response matching my requirement.

I have a custom macro for which i am creating a header file. I include this header file into another calling macro. I call the header file procedure from within this calling macro. It works fine so far. But now i need to pass parameters into the procedure that i have written in the header file. Is there a simple way to do this?

Thanks.
 
If you're looking to pass one variable back and forth between two macros, then declare it as Global.

Code:
'  Macro1.EBM
Global varVariable

Sub Main
    MsgBox varVariable
    varVariable = "Macro 1 Value"
    MsgBox varVariable
End Sub

Code:
'  Macro2.EBM
Global varVariable

Sub Main
    MsgBox varVariable
    varVariable == "Macro 2 Value"
    MsgBox varVariable
End Sub

One thing you will notice is that varVariable will keep it's value. So you will have to reset varVariable manually. Closing the program and opening it back up will not reset the value of varVariable.


If you want to use a variale in multiple subroutines then simply Dim it before your include.
Code:
'  Include.EBH
Sub IncludeSub
    varVariable = "Include"
End Sub

Code:
'  Main.EBM
Dim varVariable
'$include "Include.ebh"

Sub Main
    varVariable = "Main"
    MsgBox varVariable
    IncludeSub
    MsgBox varVariable
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top