Dan Shelby
2003-10-13 16:55:09 UTC
I am writing a system which includes several diverse utilities and which
includes several forms. Since it would be nice to use some of the more
common variables throughout the system, it would likewise be nice to only
have to dim these variables once. From what I read, the way to go about
doing this is to insert the common variables into a named public type object
and all of this within a .bas file. In my system I chose to set this up as:
public type menudata.
this is followed by listing each common variable followed by a
characteristic (string, single, etc). Then all of this is followed by an
end type line.
Finally, it was my understanding that this would allow these variable names
to be used throughout the system. When I tried to run it, each usage of one
of these variables caused a 'variable not existent' or some such error.
Then I went to the form load and inserted the statement dim xyz as menudata
and then added xyz. in front of the variables thinking that this would make
the variables 'known' to all of the subroutines called from withing that
form. This, likewise, resulted in the "variable not existent" error. To
make things work I had to include the statement "dim xyz as menudata" in
each subroutine. The system works fine this way but it just doesn't seem to
be what I had thought setting up the .bas file was supposed to do for me.
What am I missing or doing wrong?
includes several forms. Since it would be nice to use some of the more
common variables throughout the system, it would likewise be nice to only
have to dim these variables once. From what I read, the way to go about
doing this is to insert the common variables into a named public type object
and all of this within a .bas file. In my system I chose to set this up as:
public type menudata.
this is followed by listing each common variable followed by a
characteristic (string, single, etc). Then all of this is followed by an
end type line.
Finally, it was my understanding that this would allow these variable names
to be used throughout the system. When I tried to run it, each usage of one
of these variables caused a 'variable not existent' or some such error.
Then I went to the form load and inserted the statement dim xyz as menudata
and then added xyz. in front of the variables thinking that this would make
the variables 'known' to all of the subroutines called from withing that
form. This, likewise, resulted in the "variable not existent" error. To
make things work I had to include the statement "dim xyz as menudata" in
each subroutine. The system works fine this way but it just doesn't seem to
be what I had thought setting up the .bas file was supposed to do for me.
What am I missing or doing wrong?