Setting a value in modules

M

mike

Hi all,

how do I change a variable in the Module from a form?

For example:

In the module (name it module1)

Dim a as string //outside of all function

Public Function setvar(setstr as string)

a=setstr //error right here

end Function

Public Function getvar()
getvar= a

End Function


Then:
In a form, I click on a command button to set a=
something by using the function setvar(some string). But
it didn't work? Is there a better way to assign a value to
the variable a in the module??

mike
 
T

TC

If the variables are defined Public, you can refer to them directly from
anywhere else.

So, in the module:
Public strMyVariable as string

Then from anywhere else (in or outside that module):
strMyVariable = "xyz"

In passing, I hope you are not really naming your variable 'a'! If so, you
need to change that pronto. Come up with a proper variable naming scheme, or
look at other developer's code to see how they do it. Variable names like
'a', 'b' etc. are guaranteed to make your code incomprehensible.

HTH,
TC
 

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