Solved

How can I store a value in a program

Posted on 2004-04-29
5
250 Views
Last Modified: 2010-05-02
Let's say I want to have a user install a path e:\somefolder for use in my vb program...  Without writing an outside config file is there a way to store the value in the program permanently, or until it is changed again?
0
Comment
Question by:John Gates
5 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 300 total points
ID: 10949164
0
 
LVL 19

Assisted Solution

by:Shauli
Shauli earned 200 total points
ID: 10949195
You can use the registry, like this:

To save in the registry:
SaveSetting your app name", "Startup", "dbPath", yourNewValue

To read from the registry:
Dim myValue as Variant
myValue  = GetSetting("your app name", "Startup", "dbPath", "your default value")

where default value is in affect when the key is not yet there, as in first installation.

These keys are stored at  HKEY_CURRENT_USER > Software > VB And VBA Program Settings > your appname

Keep in mind that these values are PER USER on the local machine.

S
0
 
LVL 14

Expert Comment

by:ajexpert
ID: 10949260
Hi dimante,
  The other way is to store the path in INI file.  When the program is first loaded it first reads the INI file.  You have the flexibilty to change the path in INI file.  Just open the file and change the path.

  Hope this helps.
0
 
LVL 17

Author Comment

by:John Gates
ID: 10949571
Thank you!  That does it :-)
0
 
LVL 9

Expert Comment

by:dancebert
ID: 10949601
No, at least not in a pure VB solution.

What would storing the info inside a program file accomplish?  What is the real problem you're trying to solve?  There are several ways to store data in a seperate file.  Each has it's pros and cons.  If we knew why you wanted to store it inside the program file, we could help you pick one of the alternatives that will solve your problem.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

12 Experts available now in Live!

Get 1:1 Help Now