?
Solved

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

Posted on 2007-04-06
4
Medium Priority
?
277 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 320 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 180 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

840 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