Variable at Module

  • Thread starter Thread starter TNGgroup
  • Start date Start date
T

TNGgroup

Hi,

a Simple Question, I have some code at my form, the code in the form is
calling a certain module and execute some code, a certain variable is set to
strTemp. but when de module is done. I still like to use that variable
strTemp in the code of my form ?

How ?
Thx
 
There are several ways to get the value back to your form.

1) Increase the "scope" of the variable by changing where you are declaring
it. If you declare it in the modules Declarations section you will make it a
"global" variable that is available throughout your application.

2) Use parameters passed ByRef (the default for VBA) when you call the
function. Assign the value of strTemp to one of these parameters. This will
change the value for the variable that correlates with that parameter when
calling procedure .

3) Have the routine in the module assign the value of strTemp to a control
on the form. You can then retrieve the value from that control when you
return to the form.
 
I missed one.

4) Change your procedure to a Function instead of a Sub. Assign strTemp to
be the return value of the function.
 
Back
Top