Solved

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

Posted on 2007-04-06
4
267 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now