Help with Global Variable - basic.visual
This is a discussion on Help with Global Variable - basic.visual ; I'm attempting to do something like
global path as string = apppath & "filename"
But this doesn't work. I already have global path as string in a module and
this is accepted just fine. however, I need to set a ...
-
Help with Global Variable
I'm attempting to do something like
global path as string = apppath & "filename"
But this doesn't work. I already have global path as string in a module and
this is accepted just fine. however, I need to set a value to this variable
to be used in all forms within the program. This is a very large
application with close to 100 forms so I really don't want to go into each
one and set the path individually for the database filename. Is there a way
around this issue?
thank you in advance.
Steve
-
Re: Help with Global Variable
never mind I figured it out - was quite simple really - i'm just stupid
sometimes. Must be because it is late.
For anyone that might be wondering the same thing. Just set the value of
path in the subform load proceedure of the first form used.
Hmmm. sometimes I wonder what I'm doing here.
LOL
Steve
"Stephen Smith" <ab8yy@bex.net> wrote in message
news:ms-dnSLt9JgzjLTVnZ2dnUVZ_trinZ2d@buckeye-express.com...
> I'm attempting to do something like
>
> global path as string = apppath & "filename"
>
> But this doesn't work. I already have global path as string in a module
> and this is accepted just fine. however, I need to set a value to this
> variable to be used in all forms within the program. This is a very large
> application with close to 100 forms so I really don't want to go into each
> one and set the path individually for the database filename. Is there a
> way around this issue?
>
> thank you in advance.
>
> Steve
>
-
Re: Help with Global Variable
A little note: watch out for backslash butt bite <g>
(air code)
ThePath = App.Path
If Right$(ThePath,1) <> "\" then ThePath = ThePath & "\"
PathFile = ThePath & "whatever.txt"
Also, I'd recommend using Public instead of Global. Global is just
there to provide backward compatability to VB3 legacy code. If you
wanted to know why your declaration didn't work... you can't assign a
value with the variable declaration. If the value isn't changeable
(won't ever change), you can do it as a constant...
Public Const Whatever As String = "Whatever value"
...but a constant isn't really suitable for something like a path, so
your best bet is to do what you discovered, declare the variable then
assign its value in a proceedure.
On May 13, 12:17 am, "Stephen Smith" <ab...@bex.net> wrote:
> never mind I figured it out - was quite simple really - i'm just stupid
> sometimes. Must be because it is late.
>
> For anyone that might be wondering the same thing. Just set the value of
> path in the subform load proceedure of the first form used.
>
> Hmmm. sometimes I wonder what I'm doing here.
>
> LOL
>
> Steve
>
> "Stephen Smith" <ab...@bex.net> wrote in message
>
> news:ms-dnSLt9JgzjLTVnZ2dnUVZ_trinZ2d@buckeye-express.com...
>
>
>
> > I'm attempting to do something like
>
> > global path as string = apppath & "filename"
>
> > But this doesn't work. I already have global path as string in a module
> > and this is accepted just fine. however, I need to set a value to this
> > variable to be used in all forms within the program. This is a very large
> > application with close to 100 forms so I really don't want to go into each
> > one and set the path individually for the database filename. Is therea
> > way around this issue?
>
> > thank you in advance.
>
> > Steve- Hide quoted text -
>
> - Show quoted text -