03-21-2011, 06:22 PM
(This post was last modified: 03-21-2011, 06:26 PM by Resistance.)
Hello everyone, this is a tutorial on how to save settings in VB. Really easy and I just learned something today (5/31/2010) from this that I never tried but should work. !
First Step, Open VS2010... Or whatever.
Next, Create a new applicaiton...
Then After done loading
Create 1 Button and then 1 TextBox, and then another textbox... name button: Save Settings.
Go Under Project > "Example Form" Properties...
Next Find The Settings Tab.
Now Edit the Tab that says "Setting" to whatever you want and do not touch the String ComboBox and the User ComboBox.
Now, For the Code of the whole form.
Thats it, this means that when you save settings from textbox1.text, then you open the same form, the settings of textbox1 and loaded under the button into TB2.
Now, For Settings, Like Options. Like This:
Do You Want To Show This Message Ever Again? (Y/N) Message Box Right?.... I Always wanted to know how to do that. Well I just found out, using this method. This is my way, even though there might be a better one this can be temporary... Really Awesome... Watch... Same Instructions. Except. Different Code. Follow Along.
First Step, Open VS2010... Or whatever.
Next, Create a new applicaiton...
Then After done loading
Create 2 Buttons name button1: Will Be Hidden/Non Hidden, button2's name will be: Hide on Next Form Startup.
Go Under Project > "Example Form" Properties...
Next Find The Settings Tab.
Now Edit the Tab that says "Setting" to "HiddenYes" without Quotes. and do not touch the String ComboBox and the User ComboBox, but edit the value to: "Yes" without quotes.
Now Erase All The Code in the Form, and Replace with this (WARNING: YOU MUST NAME ALL THE PROPER BUTTONS TEXT TO MATCH THE IMAGE BELOW FOR THIS TO WORK AND NOT GET CONFUSED
Enjoy, post a comment if you need help. This really works and is Freaking Awesome.
First Step, Open VS2010... Or whatever.
Next, Create a new applicaiton...
Then After done loading
Create 1 Button and then 1 TextBox, and then another textbox... name button: Save Settings.
Go Under Project > "Example Form" Properties...
Next Find The Settings Tab.
Now Edit the Tab that says "Setting" to whatever you want and do not touch the String ComboBox and the User ComboBox.
Now, For the Code of the whole form.
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
My.Settings.Example = (TextBox1.Text) 'Gets the Value of TB1, Sets the String.
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox2.Text = My.Settings.Example 'Loads the String that was set from TB1
End Sub
End Class
Thats it, this means that when you save settings from textbox1.text, then you open the same form, the settings of textbox1 and loaded under the button into TB2.
Now, For Settings, Like Options. Like This:
Do You Want To Show This Message Ever Again? (Y/N) Message Box Right?.... I Always wanted to know how to do that. Well I just found out, using this method. This is my way, even though there might be a better one this can be temporary... Really Awesome... Watch... Same Instructions. Except. Different Code. Follow Along.
First Step, Open VS2010... Or whatever.
Next, Create a new applicaiton...
Then After done loading
Create 2 Buttons name button1: Will Be Hidden/Non Hidden, button2's name will be: Hide on Next Form Startup.
Go Under Project > "Example Form" Properties...
Next Find The Settings Tab.
Now Edit the Tab that says "Setting" to "HiddenYes" without Quotes. and do not touch the String ComboBox and the User ComboBox, but edit the value to: "Yes" without quotes.
Now Erase All The Code in the Form, and Replace with this (WARNING: YOU MUST NAME ALL THE PROPER BUTTONS TEXT TO MATCH THE IMAGE BELOW FOR THIS TO WORK AND NOT GET CONFUSED
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
My.Settings.HiddenYes = "Yes"
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Settings.HiddenYes = "Yes" Then
Button2.Hide()
MsgBox("Button is Hidden", 48, "Hidden Status")
Else
If My.Settings.HiddenYes = "No" Then
Button2.Show()
MsgBox("Button is Not Hidden", 48, "Hidden Status")
End If
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
My.Settings.HiddenYes = "No"
End Sub
End Class
Enjoy, post a comment if you need help. This really works and is Freaking Awesome.