Solved

Save Feature

Posted on 2003-11-06
8
282 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
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Accepted Solution

by:
lampy24 earned 30 total points
Comment Utility
Here is link for a guide for either config (ini) file or using the registry:

http://www.thescarms.com/vbasic/registry.asp
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 85

Expert Comment

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

Expert Comment

by:Arthur_Wood
Comment Utility
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
Comment Utility
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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

743 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

17 Experts available now in Live!

Get 1:1 Help Now