Home All Groups Group Topic Archive Search About

Two Relatively Simple Questions

Author
11 Jan 2006 2:22 PM
The Confessor
First,

I have four Visual Basic .Net projects in my Visual Studio solution. Each
project modifies and/or uses information in four random access files in
different ways. Hence a large portion of code is shared between two or more
of these four projects.

This leads to difficulties, since modifications to code in one project must
be mirrored in the other projects to prevent bugs & errors. For example, I
eventually traced one nasty bug that caused a display error in a ListBox to
my failure to modify a <VBFixedString(15)> that I'd increased to 17 in the
other projects.

Can I solve this by adding the same module to each of my four projects and
declaring variables common to all of them only in there?

(Would this also allow me to have routines common to all projects?)

Second,

I reference those four files using the following constants:

    Const PointsFile = "C:\Bike Racer\Shared Data\Points.dat"
    Const SegmentsFile = "C:\Bike Racer\Shared Data\Segments.dat"
    Const RoadsFile = "C:\Bike Racer\Shared Data\Roads.dat"
    Const ConfigFile = "C:\Bike Racer\Shared Data\Config.dat"

This, of course, means that the programs must always be installed to C:
\Bike Racer to run...

How would I set them equal to
"[Directory Application is Installed In] & "\Shared Data\[?????].dat"

Thanks in advance for any assistance,

The Confessor

Author
11 Jan 2006 3:48 PM
Cyril Gupta
Well, Yes I am sure you can have a common module in all the four projects.
Just add that module to your project.

For the second problem, use this: -

Application.StartupPath

Cheers
Cyril
Author
11 Jan 2006 4:46 PM
The Confessor
Show quote Hide quote
"Cyril Gupta" <nom***@mail.com> wrote in
news:#Y62GbsFGHA.4036@TK2MSFTNGP12.phx.gbl:

> Well, Yes I am sure you can have a common module in all the four
> projects. Just add that module to your project.
>
> For the second problem, use this: -
>
> Application.StartupPath
>
> Cheers
> Cyril
>
>

Thank you, Cyril... my guess had been IO.Directory.GetCurrentDirectory, but
I was hoping for something that would allow me to keep declaring them as
constants rather than variables (since they *are* constant once declared),
but that ain't gonna happen, is it?

As for my problem of reproduced code (specifically, declarations)...

Well, when I declare my variables in a common module which I've added to
each project and subsequently remove the declarations in each specific
project, they don't seem to recognized the declarations in the module...

Is there any way to tell Visual Basic to basically "Look *here* for more
declarations"?
Author
11 Jan 2006 6:33 PM
The Confessor
The Confessor <inva***@reply.to.group> wrote in
Show quoteHide quote
news:Xns974877BC98218invalidreplytogroup@130.81.64.196:

> Thank you, Cyril... my guess had been
> IO.Directory.GetCurrentDirectory, but I was hoping for something that
> would allow me to keep declaring them as constants rather than
> variables (since they *are* constant once declared), but that ain't
> gonna happen, is it?
>
> As for my problem of reproduced code (specifically, declarations)...
>
> Well, when I declare my variables in a common module which I've added
> to each project and subsequently remove the declarations in each
> specific project, they don't seem to recognized the declarations in
> the module...
>
> Is there any way to tell Visual Basic to basically "Look *here* for
> more declarations"?

Uh, just to preempt any reply...

I'm an idiot.

The variables must, of course, be declared as Public in the module to be
accessed by the form.

Thanks for you help, Cyril.
Author
11 Jan 2006 7:08 PM
The Confessor
The Confessor <inva***@reply.to.group> wrote in
news:Xns974889F9D8860invalidreplytogroup@130.81.64.196:

> I'm an idiot.
>
> The variables must, of course, be declared as Public in the module to be
> accessed by the form.
>
> Thanks for you help, Cyril.

One further caveat: When you attempt to add the existing module to your
other projects, you must *link* to it. Otherwise, a copy of the current
version of the module will simply be placed in your project's directory,
and you'll be left with the same problem as before: modifying four
different files instead of one.