somerandomperson

I just want to be able to have simple features like a splitter remaining in the same spot the user had it it when the user closes the program down. It would be a lot simplier for me if there was some way for a variable or string to retain its value after the app shuts down and be able to use it on restart. Is that possible Also how would I make it to where the code to save would be run when the the user tries to close down


Re: Visual Basic Language easier way to save data than a database before app shut down

PEng1

You can use the Settings Namespace to preserve values in the system registry. Click on the My Project folder in the Solution explorer then on the left hand side of that mess there will be a tab labeled Settings, you can enter settings variables here. To get to them in code Type My.Settings.VariableName.

You can use the FormClosing event to save the current variables into the settings.

HTH.






Re: Visual Basic Language easier way to save data than a database before app shut down

somerandomperson

Thanks that works perfectly but is there a way to have a string array or something simmiliar to be saved With every method I've tried I get the following error while debugging when trying to add a value.. Please inclose code if it is possible in response..

An unhandled exception of type 'System.NullReferenceException' occurred. Additional information: Object reference not set to an instance of an object.





Re: Visual Basic Language easier way to save data than a database before app shut down

Riquel Dong ¨C MSFT

Hi Somerandomperson,

Based on your post, my understanding of your question is that your application saves the data which is needed for running the application. I recommend you use the My.Settings class to achieve this. This class has made storing application and user settings much simpler in Visual Basic 2005.

The new Application Settings architecture addresses these needs by providing an easy way to store both application-scoped and user-scoped settings on the client. Application Settings works by persisting data as XML to different configuration (.config) files, depending on whether the setting is application-scoped or user-scoped. Application-scoped settings are read-only. Because the application-scoped settings are program information, you will typically not need to overwrite them. By contrast, user-scoped settings can be read and written safely at run time, even if your application runs under partial trust. So you can use the user-scoped settings to achieve this. For more information, visit Using My.Settings in Visual Basic 2005. It should satisfy your requirements.

Best regards,

Riquel.