I can't get 'Public UserID As String' to work right.

  • Thread starter Thread starter Trint Smith
  • Start date Start date
T

Trint Smith

I did have UserID as 'Dim UserID As String'. Ok, when I made it 'Public
UserID As String', in the Public Area of one program and took out all
the 'local' declairations of it, even in the other programs that need to
see the same value of UserID, UserID was getting the 'UserID is not
declaired' message in the other programs. Do I have to put 'Public
UserID As String' in the Public areas of all my programs, and if I do a
UserID = "something" in one program, will it still have that value in
the other programs? Or is there a better way?
Thanks,
Trint

.Net programmer
(e-mail address removed)
 
To set up a static member, you will want to have it in a module. This may
not be what you are aiming at. For application, consider setting up a
singleton as you application object. If the values are app wide, you can
also make them static (Shared keyword in VB.NET).

To go across programs, you will have to make a service, set up the value in
some form of persistant storage, or have a means of passing the value across
multiple apps.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Let me suggest that you post an example. I'm not sure we understand what
you mean by "one program" and "other programs." Post a few lines
demonstrating "this works" and "this doesn't work." But "no" you surely do
not declare what you hope to be a public variable in more than one place.
 
I think you need to declare the variable as 'Public' in a module rather than
in one particular form's declaration area.
 
So where do I put 'Public UserID As String' so that all the little blue
underscores under UserID go away? :)
I literally, WHERE does it go?
Thanks,
Trint


.Net programmer
(e-mail address removed)
 
Back
Top