Solved

Save Feature

Posted on 2003-11-06
8
284 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
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
 
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
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.

 
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

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

919 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

13 Experts available now in Live!

Get 1:1 Help Now