Solved

Resetting default value of text box at runtime – VB.Net, Visual Studio 2003, Windows Applications.

Posted on 2007-04-06
4
271 Views
Last Modified: 2011-09-20
Hello

I’d like to have a user open my .exe Windows Application, type some text in a text box, hit a button which makes this text it’s default the next time the user opens the applications.

Is this possible without storing the default text in a text file?

Any suggestions would be appreciated.

Thanks.
Iain
0
Comment
Question by:IainTheVBALearner
  • 2
4 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 80 total points
ID: 18864840
You can store it in the AppSettings...

See: http://www.codeproject.com/netcf/cConfig.asp
0
 
LVL 3

Expert Comment

by:r1937
ID: 18867308
I'm not sure about VB2003
however In VS2005 you can double click "My Project" and in settings, type in the setting name, type and scope (per user or for all users).

To access/set these values:

My.Settings.MySetting = "Test Value"

These will be saved when the application closes if save my setings on shutdown is checked or use
My.Settings.Save
0
 
LVL 3

Assisted Solution

by:r1937
r1937 earned 45 total points
ID: 18867369
Or use registry to save application.

Imports Microsoft.Win32
to open----------
        Dim RegKey As RegistryKey
        Try
            RegKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\MyAppName", True)
            txtName.Text = RegKey.GetValue("Name")
            txtAddress.Text = RegKey.GetValue("Address")
            txtTelNo.Text = RegKey.GetValue("TelNo")
        Catch
            'No Registry Entries
        End Try
to save----------
           Try
                RegKey = Registry.CurrentUser.OpenSubKey("SOFTWARE", True)
                RegKey.CreateSubKey("MyAppName")
                RegKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\MyAppName", True)
                RegKey.SetValue("Name", txtName.Text)
                RegKey.SetValue("Address", txtAddress.Text)
                RegKey.SetValue("TelNo", txtTelNo.Text)
            Catch
                MsgBox("Error")
            End Try
0
 
LVL 3

Author Comment

by:IainTheVBALearner
ID: 18910231
What a palava....thanks for the comments!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question