Solved

How can I store a value in a program

Posted on 2004-04-29
5
255 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, CISSP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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, CISSP
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

691 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