Thread: XML files
View Single Post
 
Old 10-06-2013, 04:45 AM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

Not sure why you are going about this the hard way.
Visual Basic.NET has a save and load of variable built in.

At design-time you define your variables to save in the project properties under the settings tab. See attached pic.

At run time your code can access each variable by name.

Code:
Public Class Form1 Public TreeCount As Long Public ElfCount As Long Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load TreeCount = My.Settings.TreeCount ElfCount = My.Settings.ElfCount '... End Sub Private Sub Button1_Click(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Button1.Click My.Settings.TreeCount = TreeCount My.Settings.ElfCount = ElfCount '... My.Settings.Save() End Sub End Class

BTW The Form_Closing Event has issues of closing before your code completes. Use some other event(s) to save your settings.
Attached Images
File Type: png Settings Tab.PNG (62.3 KB, 7 views)
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 10-06-2013 at 05:48 AM.
Reply With Quote