Thread: passing strings
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
onedaywhen onedaywhen is offline
external usenet poster
 
Posts: 459
Default passing strings

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.

"Josie Dethiers" wrote in message ...
I give almost the same answer to Sirron in another thread ("Passing a string
value") but I used "MyVar" in module2 and not "module1.myVar". Isn't it
required only if the variable has been declared in several modules ?

Josie

"microsoft" a écrit dans le message de news:
...
in one module (module1), declare a public varaible (public myVar) .. in

the
other module (module2) state module1.myVar = "blahblahblah"

theHman

"Sirron" wrote in message
...
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.