Hello,
I hope i posted this to the right forum, otherwise, move me.
In my application the user shall be able to change settings, the settings are save to a file so that they hold their value until next time the user runs the application. Now, Ive done like this:
In the settings form:
- when the form is loaded the settings file is opened and stored in the structure Settings. The settings are loaded into the controls on the form.
- user changes settings.
- user clicks save settings and the settings are stored in the structure Settings.
- the values of the settings structure are saved to the settings file by random access.
When the application runs:
- the settings file is opened and the settings are stored in the structure Settings.
In this way the subroutines and functions should be able to get settings data from this Settings structure. My application consists of many classes and forms so each class has the following declaration;
The FileIO class and the Settings structure are declared in this way:
The FileIO class is locate in the same file/form as the first form (but not within another class), could this be what causes it? I cant create a class that stands all alone which belongs to no form.
Seems like declaring the structure as Shared would be the right way, since shared variables have a lifetime that lasts thoughout the entire execution, until its terminated. Visual Basic does not like this at all and says:
"Shared is not valid on a Structure declaration"
I hope you understand the problem
Regards,
Simon.
I hope i posted this to the right forum, otherwise, move me.
In my application the user shall be able to change settings, the settings are save to a file so that they hold their value until next time the user runs the application. Now, Ive done like this:
In the settings form:
- when the form is loaded the settings file is opened and stored in the structure Settings. The settings are loaded into the controls on the form.
- user changes settings.
- user clicks save settings and the settings are stored in the structure Settings.
- the values of the settings structure are saved to the settings file by random access.
When the application runs:
- the settings file is opened and the settings are stored in the structure Settings.
In this way the subroutines and functions should be able to get settings data from this Settings structure. My application consists of many classes and forms so each class has the following declaration;
Now, I can refer the Settings structure in this way:Private Settings As FileIO.Settings
This, returns nothing though, TheVariable is empty. Confusing, because the Settings structure was set in the Load event of the first form. So Ive tested it many times and discovered that the Settings structure has no values other than in the first form. Seems like Private Settings As FileIO.Settings makes a new, empty intstance of Settings.Settings.TheVariable
The FileIO class and the Settings structure are declared in this way:
Public Class FileIO
Public Structure Settings
<VBFixedString(100)> Dim PicPath As String
<VBFixedString(100)> Dim SoundPath As String
<VBFixedString(1)> Dim BackColor As String
End Structure
The FileIO class is locate in the same file/form as the first form (but not within another class), could this be what causes it? I cant create a class that stands all alone which belongs to no form.
Seems like declaring the structure as Shared would be the right way, since shared variables have a lifetime that lasts thoughout the entire execution, until its terminated. Visual Basic does not like this at all and says:
"Shared is not valid on a Structure declaration"
I hope you understand the problem
Regards,
Simon.