Two Relatively Simple Questions

  • Thread starter Thread starter The Confessor
  • Start date Start date
T

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
 
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
 
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"?
 
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.
 
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.
 

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

Back
Top