4 Replies - 44254 Views - Last Post: 19 December 2009 - 02:11 PM Rate Topic: -----

#1 unlimited24  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 28-August 08

How to use my.settings in VB.Net

Posted 03 June 2009 - 01:27 PM

hi. I want to find out how I can store text from a textbox, close the form and next time when I start it again, I want to load the text into the textbox that was previous entered.

I have created a new application setting thing as a string.

then in the textbox1_textchanged event I wrote

My.Settings.Textbox1 = TextBox1.Text
		My.Settings.Save()


I do not know from then on. please help :)

Is This A Good Question/Topic? 0
  • +

Replies To: How to use my.settings in VB.Net

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9392
  • View blog
  • Posts: 35,273
  • Joined: 12-June 08

Re: How to use my.settings in VB.Net

Posted 03 June 2009 - 02:09 PM

MSDN rocks.

http://msdn.microsof...611(VS.80).aspx
Was This Post Helpful? 0
  • +
  • -

#3 unlimited24  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 45
  • Joined: 28-August 08

Re: How to use my.settings in VB.Net

Posted 03 June 2009 - 03:17 PM

well I did came across this but I just don't get it. so was hopeing someone can give me a simple example of it...
Was This Post Helpful? 0
  • +
  • -

#4 PlanetUber  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 24
  • Joined: 03-June 09

Re: How to use my.settings in VB.Net

Posted 03 June 2009 - 04:39 PM

View Postunlimited24, on 3 Jun, 2009 - 02:17 PM, said:

well I did came across this but I just don't get it. so was hopeing someone can give me a simple example of it...


Well, to break it down simply for your situation you need to follow these steps:
1. Create the setting in the project and give it a meaningful name eg. TextBoxContents

2. Next you will need to add the code to run on the TextChanged event of the TextBox1. This code is just as you have in the original post. However, as I am a performance junkie I would suggest moving the save method to the textbox's Leave or LostFocus event. This will prevent the application saving the contents on each keystroke
	   
'Save the contents of the textbox each time focus is lost
My.Settings.TextBoxSave = TextBox1.Text
'Commit the changes
My.Settings.Save()


3. To the load the contents of the text box next time the form loads you will then need to add code to the Form's Load event. Loading the text is simply a case of reversing the code above. Specifically:
'Read the contents of my.settings.TextBoxSave
TextBox1.Text = My.Settings.TextBoxSave



I hope this helps mate. Also, remember to use the search box in the top right... There are plenty of topics about this already.

Let me know how you go.
Was This Post Helpful? 0
  • +
  • -

#5 billyboy630  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 94
  • Joined: 09-October 09

Re: How to use my.settings in VB.Net

Posted 19 December 2009 - 02:11 PM

Can you save all settings?
My program connects to a database and i want the user to be able to close the program and re-open to last settings

could i do this at close ?

MySettings.Application
Application.Exit

I am not at a computer with VB , just came across this post
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1