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
#2
I honestly know all this, but this is really good.
A really useful thread if I might say.
Thanks.
Reply
#3
I mainly use this to save settings for like font colors,fonts and background colors for applications. Thanks for the feedback though.
~ Digital-Punk
Reply
#4
Yes It's Really Useful.But It's Stores The All Settings In The File Settings.xml Which we can easily see using notpad.so It's Became useless when we want to make some application that stores secret string like password or licence key etc.
Reply
#5
(10-14-2011, 01:07 AM)CodingWorm Wrote: Yes It's Really Useful.But It's Stores The All Settings In The File Settings.xml Which we can easily see using notpad.so It's Became useless when we want to make some application that stores secret string like password or licence key etc.

You would probably want to save a password to the registry correct?
~ Digital-Punk
Reply
#6
Yeah You are Right.In Registry with encryption.
Reply
#7
looks very interesting thanku for this im trying to learn
Reply
#8
You can still save the setting as an encrypted hash and just decrypt it. Also, for future reference using the ApplicationSettings > PropertyBinding, you can auto-save settings so you don't have to call them up in the Form_Load...

[Image: bb308902.vb-5-8(en-us).gif]

Most properties work, but I did notice for the NumericUpDown's you need to save the setting (My.Settings.Save()) in the ValueChanged event. Hope this helps someone, great shortcut ;)
Reply


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

Forum Jump:


Users browsing this thread: 1 Guest(s)