About User Entered Data [modified]
-
Hey all, Newbie question here that probably has a simple solution that I can't seem to find, but I'm new to programming and am still playing around. ;) What I'm trying to do, is create a program that will allow someone to enter data into a couple textboxes. What I want to happen is, to have a button that allows the user to "save" his/her entered data in these textboxes so that when they launch the program again, these changes are displayed until they are changed again. Can anyone give me some sample code that would accomplish this? Any help or links to appropriate articles would be greatly appreciated. Thanks! Oh, forgot to mention that I'm using VB.Net 2003. -- modified at 12:33 Wednesday 26th July, 2006
-
Hey all, Newbie question here that probably has a simple solution that I can't seem to find, but I'm new to programming and am still playing around. ;) What I'm trying to do, is create a program that will allow someone to enter data into a couple textboxes. What I want to happen is, to have a button that allows the user to "save" his/her entered data in these textboxes so that when they launch the program again, these changes are displayed until they are changed again. Can anyone give me some sample code that would accomplish this? Any help or links to appropriate articles would be greatly appreciated. Thanks! Oh, forgot to mention that I'm using VB.Net 2003. -- modified at 12:33 Wednesday 26th July, 2006
Hi, you can do this using the registry. Well thats what I did. To save the settings to the registry you need this code
My.Computer.Registry.CurrentUser.CreateSubKey("_name of your program_") My.Computer.Registry.SetValue_("HKEY_CURRENT_USER\_name of your_ _program_","_textbox name_", _textbox name_.Text)
To load the data back into the textbox you can use this._textbox name_.Text = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\_program name_", "_textbox name_", Nothing)
You need to put this code in a button or a timer and something like that. Good luck:laugh: -- modified at 13:23 Wednesday 26th July, 2006 -
Hi, you can do this using the registry. Well thats what I did. To save the settings to the registry you need this code
My.Computer.Registry.CurrentUser.CreateSubKey("_name of your program_") My.Computer.Registry.SetValue_("HKEY_CURRENT_USER\_name of your_ _program_","_textbox name_", _textbox name_.Text)
To load the data back into the textbox you can use this._textbox name_.Text = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\_program name_", "_textbox name_", Nothing)
You need to put this code in a button or a timer and something like that. Good luck:laugh: -- modified at 13:23 Wednesday 26th July, 2006 -
Hi, you can do this using the registry. Well thats what I did. To save the settings to the registry you need this code
My.Computer.Registry.CurrentUser.CreateSubKey("_name of your program_") My.Computer.Registry.SetValue_("HKEY_CURRENT_USER\_name of your_ _program_","_textbox name_", _textbox name_.Text)
To load the data back into the textbox you can use this._textbox name_.Text = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\_program name_", "_textbox name_", Nothing)
You need to put this code in a button or a timer and something like that. Good luck:laugh: -- modified at 13:23 Wednesday 26th July, 2006Just wanted to thank you again for the help. I got it to work properly, although using a slightly 'different' wording, i suppose. Your code was giving me some errors, so I looked for a couple of different ways of doing the same thing and this one ended up working for me. My code ended up looking like this:
Dim CompSN_Reg As Microsoft.Win32.RegistryKey CompSN_Reg = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("ACQ01") CompSN_Reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("ACQ01", True) CompSN_Reg = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("ACQ01\\CompSN") CompSN_Reg.SetValue(txt_ACQ01_Comp_SN.Text, txt_ACQ01_Comp_SN.Text)
Same idea in theory... but so fickle. Ahhh, I'm constantly reminded why I've always hated programming. :laugh: Anyways, Thanks! :) -
Just wanted to thank you again for the help. I got it to work properly, although using a slightly 'different' wording, i suppose. Your code was giving me some errors, so I looked for a couple of different ways of doing the same thing and this one ended up working for me. My code ended up looking like this:
Dim CompSN_Reg As Microsoft.Win32.RegistryKey CompSN_Reg = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("ACQ01") CompSN_Reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("ACQ01", True) CompSN_Reg = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("ACQ01\\CompSN") CompSN_Reg.SetValue(txt_ACQ01_Comp_SN.Text, txt_ACQ01_Comp_SN.Text)
Same idea in theory... but so fickle. Ahhh, I'm constantly reminded why I've always hated programming. :laugh: Anyways, Thanks! :) -
Hey all, Newbie question here that probably has a simple solution that I can't seem to find, but I'm new to programming and am still playing around. ;) What I'm trying to do, is create a program that will allow someone to enter data into a couple textboxes. What I want to happen is, to have a button that allows the user to "save" his/her entered data in these textboxes so that when they launch the program again, these changes are displayed until they are changed again. Can anyone give me some sample code that would accomplish this? Any help or links to appropriate articles would be greatly appreciated. Thanks! Oh, forgot to mention that I'm using VB.Net 2003. -- modified at 12:33 Wednesday 26th July, 2006
Beside using the registry, you can use My.Settings to store your setting. You have to create your setting in Design Time You can set this in Project Properties and point to Settings Tab. The settings will be save into XML format in your application path here's the code to change and save the settings ---------------------------------------- My.Settings.UserName = "BrazenSix" My.Settings.Subject = "About what??" My.Settings.Save() to retrieve settings value ---------------------------------------- Dim UName, USubject As String UName = My.Settings.UserName USubject = My.Settings.Subject