Well you've stumbled on a situation where you have and plethora of answers, i can just list a few:
- Application Settings
- Stream reader writer
- FileOpen, FileClose, Put, Get excetera
Well thats for the saving the files.
The simplest way is the Application settings. To do this go to the My Project tree node in solution explorer.
Double click it and a new tab shall open up, now inside this are loads of tabs on there side going down the left hand side of the page, now click on the one that says settings.
Click in the highlighted first item in the listview (i think it says setting to begin with) and write in that what name you want to give the setting,
then the next column along defines what type of variable,
leave the scope as application,
and also leave the value blank aswell.
Now you can use this code:
Code:
Public Sub SaveSettings()
My.Settings.[SettingName] = [SettingValue]
My.Settings.Save()
End Sub
You could obviously elaborate on that also explore the methods and properties of the Settings class.
The other decent way is to do this:
Code:
Public Structure FileSettings
<VBFixedString(244)>Dim SettingName As String
Dim SettingValue As Object 'Unless you know what you would be saving
End Structure
'Effectively this acts as a record in a table within a database, just without the database
'and the table is a file
Public Sub WriteSettings()
Dim newSetting As New FileSettings
Dim settingStructureLength As Integer = Len(newSetting) 'Need to know how long each record is
newSetting.SettingName = [SettingName]
newSetting.SettingValue = [SettingValue]
Dim ffInt As Integer = FreeFile() 'Find a free file in memory
FileOpen(ffInt, [Filename/Filepath], Random, , , settingStructureLength) 'This opens, creates or what ever needs to be done to access that file
'The random means that it accesses any where in the file at specified points defined by
'the length of a record
FilePut(ffInt, newSetting, 1) 'Put the object into the file
FileClose(ffInt) 'This closes the file so that it can be later accessed and all that
End Sub
These aren't very comprehensive and its all done of the top of my head so some of it could be slightly wrong but i'm sure this is a good base for you to build on, i came up with all this on less prompts and with less knowledge(like no knowledge).
If you would like me to elaborate then just post back!