That's all the settings we need for this tutorial so save your changes. Close the Settings Window and set focus back to the Form1 Designer Window.
Add a TextBox to the form and stretch it almost the entire width of the form. Now select the form itself and double-click to open the code window for the Form1_Load event. Type the following code inside the Form1_Load event:
Me.BackColor = My.Settings.DefaultFormColor
Me.TextBox1.Font = My.Settings.DefaultFont
Me.TextBox1.ForeColor = My.Settings.DefaultFontColor
Me.TextBox1.Text = My.Settings.DefaultName
Press F5 to see your progress in action. You should have a form that looks similar to the following image:
Saving Setting value changes at runtime
Add a Form1_FormClosing event. Type this code:
My.Settings.DefaultName = Me.TextBox1.Text
Now press F5 to run. This time, change the text in the textbox from 3-bSoftware.com to your name. Close the form. Close the project. Close Visual Studio. If you like, you can restart your computer too.
Next time you run the "VbCity Sample Project" you will see the name you just typed in the TextBox.
You can use this same process to save any of the 'User Scope' variable changes. Try practising by saving different values for the DefaultColors, or DefaultFont. Good luck!
Thank you for reading my article, Dave.