Where can I put this string so it is visible to all programs?

T

Trint Smith

I've looked for a 'module' and used the class viewer to put it in there,
but 'Public UserID As String' is still not a globally visible string.
How do I do this please?
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
R

Richard K Bethell

Trint Smith said:
I've looked for a 'module' and used the class viewer to put it in there,
but 'Public UserID As String' is still not a globally visible string.
How do I do this please?
Thanks,
Trint

If you are writing a library, you would typically expose a string that is
gettable and settable via a property.

R.
 
C

CJ Taylor

Modules are a little weird in VB.NET, don't act like they did in vb6 (from
what I've seen, I try to avoid them like the plague).

Anyways, you might want to do

Imports myModule

on top of the classes you want to use it in. Personally, I would use a
Class declaration and call a shared varialble

i.e

public class myClass

public shared UserID as Integer

end class
 
H

Herfried K. Wagner [MVP]

* Trint Smith said:
I've looked for a 'module' and used the class viewer to put it in there,
but 'Public UserID As String' is still not a globally visible string.

What exactly do you mean with "globally"?
 
T

Trint Smith

I figured it out...
In VS.NET right click on the project in the solution viewer and select
add> add new item> module> open>
It looks like this of course:

Module Module1

End Module

then just stick it in there so that it looks like this:

Module Module1
Public UserID As String
End Module

And anything can be seen by any program in the project.
Thanks,
Trint


.Net programmer
(e-mail address removed)
 
H

Herfried K. Wagner [MVP]

* "Abubakar said:
But I'll encrourage u to use Shared member variables for this purpose.

.... in a class. Or you can implement the singleton design pattern...
 

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