Solved

How can I store a value in a program

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

948 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

22 Experts available now in Live!

Get 1:1 Help Now