passing strings

S

Sirron

I'm trying to pass a string value from one module to
another how can you do this?

I have a string that contains a numerI need to pass that
string to another module to do the rest of the code.
 
M

microsoft

in one module (module1), declare a public varaible (public myVar) .. in the
other module (module2) state module1.myVar = "blahblahblah"

theHman
 
O

onedaywhen

I've never used a public variable. Shall I say that again? I've never
used a public variable. If I've never needed one, the chances are you
don't them either. Here's a hint: you should think in terms of passing
values between sub procedures (properties and methods - subs and
functions) not modules.

The closest I've come is a public property Get/Let pair in a class
module, which I would call from outside the class as
InstanceName.PropertyName.

When you use a public variable in a class module VBA implicitly makes
it a public property, technically called a 'field' I believe. You can
explicitly declare property Get/Let pairs in standard modules and get
the implicit behaviour of public variables in standard modules too.

And this is the Module1.MyVar syntax you are referring to i.e. the
equivalent of InstanceName.PropertyName.

But properties in a standard module, implicit or otherwise, don't
really make a lot of sense.
 

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