Solved

Save Feature

Posted on 2003-11-06
8
288 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 85

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
Independent Software Vendors: 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 30 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 85

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2013 combo box not working 3 58
Help with retrieving partial value from a column using VB.NET 4 53
Advice in Xamarin 21 109
Assign a value in Excel V-Basic 3 29
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 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…
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…

749 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