Solved

How can I store a value in a program

Posted on 2004-04-29
5
252 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel VBA combine two working workbooks 8 54
Reading the Contents of a Directory In Access VBA 5 70
How to read File Date Created using VB6 8 39
Excel Automation VBA 19 70
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

777 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