?
Solved

Save Feature

Posted on 2003-11-06
8
Medium Priority
?
292 Views
Last Modified: 2010-05-03
I have a stand-alone EXE, and this EXE has 3 variables that are used for some complex calculations. I have made it so that these variables can be changed if need be, but when the exe is re-opened those numbers must be changed again. Is there a way for me to change those variables once, save it, and not have to correct them again (unless they actually need to change.

The variables right now are 68, 63, & 9. Later, they may need to be changed to 70, 65, & 15. And even further down the road, they may need to be changed again. I just don't want to have to code and re-compile unless necessary. Thanks!
0
Comment
Question by:JFrye
[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
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9696071
The fastest way would be to pass them in as parameters to your application and then create a shortcut.

app.exe 68 63 9

Then in your code you can retrieve the items using the command function.

Private Sub Form_Load()
    Dim parameters As Variant
    parameters = Split(Command())
   
    Dim a As Integer
    For a = LBound(parameters) To UBound(parameters)
        Debug.Print "Parameter " & a; " = " & parameters(a)
    Next a
End Sub

Or you could save those values in the registry and provide some way in app to update them.

Private Sub Form_Load()
    SaveSetting "MyApp", "Variables", "Value1", 68
    SaveSetting "MyApp", "Variables", "Value2", 63
    SaveSetting "MyApp", "Variables", "Value3", 9

    Dim a As Integer, b As Integer, c As Integer

    a = GetSetting("MyApp", "Variables", "Value1")
    b = GetSetting("MyApp", "Variables", "Value2")
    c = GetSetting("MyApp", "Variables", "Value3")
   
    Debug.Print a, b, c
End Sub
0
 
LVL 1

Expert Comment

by:lampy24
ID: 9696087
Why not save those values to a  config file or the registry!  Which will persist the values from each opening of the exe.  So, the values can be changed from without a recompile.  For your app I suggest using a config file and everytime the app is launched you just open the file and read in the values and when you want to change the values just rebuild the file with the values.

Good Luck
0
 

Author Comment

by:JFrye
ID: 9696121
Well, I'd rather not have any registry entries or extra files. This app is actually located on a corporate network, and all PCs have the registry locked. That's why I need just one file - the app itself. If it isn't possible, that's fine. Just let me know if it absolutely isn't possible to do it the way I prefer. Thanks!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
lampy24 earned 90 total points
ID: 9696135
Here is link for a guide for either config (ini) file or using the registry:

http://www.thescarms.com/vbasic/registry.asp
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9696143
Use my first suggestion then and pass them in as parameters.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 9696367
you asked "Is there a way for me to change those variables once, save it, and not have to correct them again (unless they actually need to change)", and yet you then say "I'd rather not have any registry entries or extra files".

Where would you want to SAVE the values if not in an 'extra file'?

The values MUST be saved somewhere, and the Registry or en External file are the only choices.

AW
0
 

Expert Comment

by:gr8white
ID: 9696554
I think you'll find that even though the registry is "locked" your app will still be able to create the entries.  THe SaveSettings command in VB writes only to a special key in the registry and can't screw up anything other than your app (for that you need to use API calls!)

Obviously the other apps running on your network PCs need to be able to store their settings in the registry.

Ken
0
 

Author Comment

by:JFrye
ID: 9696709
I wanted to be able to just alter the app itself without re-coding and re-compiling. But after a little thought, it isn't really that big of a deal compared to a config file.

A registry entry is out of the question since multiple PCs will use this app, and I can't change everyone's registry.

So, I'll take lmapy's answer. Thanks, everyone!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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 …
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

801 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