Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Vb.Net]Save user settings with "My.Settings"[TUT]
#1
This is a really useful way to save the users settings in your apps. Ive seen other ways which are good but this works for me.

1. Create a New project call it whatever you want, I named mine "MySettings".

2.Add a Textbox and Button control to your app.
The buttons text should read "Save".
On the textbox, I set to multiline.

[Image: form.png]

3. Click on My Project in the soultion explorer
4. Click the Settings Tab
5. Add a new "Name" for your setting, this name will be used kinda like a variable. I named mine textsaved.
6. Under the "Type" column click "String" I actually think this is by default. Now you could use the other Data types as well, depending on what your really trying to save.
7. Under scope you want "User" scope cause its the user saving not the "Application".
8. Optional: depending on the setting, for "value" it would be a text value since where using a string type. But for now just leave it blank cause where going to fill that up with user input.

[Image: myprojects.png]

Heres the code where going to use:

[Image: codev.png]

So starting typing some non-sense in the textbox.
Then click the save button and close the app.
Reopen the app and bam your text appears. Try it without clicking the save button and you get nothing.

Basicly in the button click event we are going to save the text in the textbox. Where not really saving the data yet just assigning it to the setting we made.

In the form closing we are actually saving. If you forget this line it will not save.

On the form load we are telling the textbox that its contents will be what was saved from the setting.

Well thats all there is to it. Hope this helps someone here.
~ Digital-Punk
Reply


Messages In This Thread
[Vb.Net]Save user settings with "My.Settings"[TUT] - by Digital-Punk - 10-12-2011, 08:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to hook the keyboard. [VB.NET] [TuT] Vorfin 92 54,207 09-23-2019, 11:55 AM
Last Post: Jamimartin
  VB.NET Port Scanner [TUT] Fragma 30 12,635 11-27-2012, 11:26 PM
Last Post: ƃu∀ ıʞƃu∀
  [TUT] MD5 Encrypter & Finder [VB.NET] Fragma 12 6,929 11-25-2012, 10:36 PM
Last Post: ƃu∀ ıʞƃu∀
  [TUT] How to make a simple WebBrowser in VB 2010! [TUT] - [ Pictures] Statics 95 55,107 10-07-2012, 06:56 AM
Last Post: a99
  [TUT]Auto-Update System[TUT] HB Virus 3 2,135 01-07-2012, 02:21 PM
Last Post: Mastermrz

Forum Jump:


Users browsing this thread: 1 Guest(s)