Terrance,
Keep in mind the difference between a class and an object. A class is what
you wrote, and an object is an instance of that class. So if you create two
instances of the class:
Dim vfObject1 As New FoxConnectionClass
Dim vfObject2 As New FocConnectionClass
They are totally different classes. Any properties set on one, will not
propagate to the other. However, the declaration (Dim) is actually declaring
a reference to the class (New FoxConnectionClass), so if you did:
Dim vfObject1 As New FoxConnectionClass
....
Dim vfObject2 = vfObject1
Now, both the vfObject1 reference and the vfObject2 reference are pointing
to the same object.
In your case, you're going to have to pass a reference to your vfClass into
your frmSplash.
So you could change your frmSplash constructor to be:
Public frmSplash(ByVal vfConnection As FoxConnectionClass)...
And then assign the passed-in reference to a local reference.
"Terrance" <Te******@discussions.microsoft.com> wrote in message
news:C3**********************************@microsof t.com...
Ok, I placed the class in the main sub but I still loose scope when I go
to a
form. Here is what my main sub looks like:
Imports System.IO
Imports System.Data.OleDb
Module MainModule
Dim vfClass As New FoxConnectionClass 'create class
Public Sub Main()
'Dim vfClass As New FoxConnectionClass 'create class
'declare object for each form.
Dim frmSplash As New fclsSplash
Dim mainForm As New fclsMain
Dim SqlLogin As New frmLogin
'Directory structure to fox table.
vfClass.mydirectory = Directory.GetCurrentDirectory & _
"\sysconn.dbf"
Try
System.Windows.Forms.Application.EnableVisualStyle s()
System.Windows.Forms.Application.Run(frmSplash)
(Remaining Code.....)
Unfortunately, when I try to access the vfClass.mydirectory method from
my
sqlLogin form it finds vfClass as not being declared. Any help would be
greatly appreciated...
"Terrance" wrote:
Hello, everyone. I was hoping if someone could help me out with a problem
that I'm trying to solve? I have a project that I'm working on. As the
splashscreen launches for an application I check the directory for the
location of a file and I assign that directory path to a class member in
my
main module; so, I have the following syntax cClass.mydirectory = (path
of
file). However, when I Load a form I have to recreate the class object
cClass
and the member mydirectory is now blank. I was under the impression that
once
a class object is created it's stored in memory and the code should be
able
to access that class member from memory. Am I wrong in assuming this? Can
a
class be made global or referenced for access from all forms? Thanks.
--
TC