Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i save data within the application

Status
Not open for further replies.

ikim2000

MIS
May 23, 2002
22
CA
Is there a way to save limited data in the exe file?
Let say I want store something like the changing values in txtFirstName or txtLastName or chkBox values and retrieve for later use...can it be stored somewhere within the controls? If so what would be the limitation?

Thanx,
Ik.
 
I Think the answer is No.

Although I could be wrong..
I would suggest saving your data into a simple text file.
and retrieve it again when needed, it is a very simple process:

to write
Open "C:\TEXTFILE.TXT" For Output As #1
Print "Whatever"
Close #1

to read
Open "C:\TEXTFILE.TXT" For Input As #1
etc etc

if you are concerned about people finding this file you could do some wierd stuff with the strings and hide the file by renaming it and saving it somewhere awkward.
 
You can also use the SaveSetting,GetSetting functions to store information in the registry for later retrieval.

Example.


SaveSetting "SampleApplication", "SavedValues", "Text1String", Text1.Text

Text1 = GetSetting("SampleApplication", "SavedValues", "Text1String", "Default")
 
rogerl101, would this work for any user or just the users with the admin previlages because of writing to the registry?

thanx,
ik.


 
>Let say I want store something like the changing values in txtFirstName or txtLastName or chkBox values and retrieve for later use

this would suggest that there are going to be many values of the same type saved (eg several first names etc) in which case a txtfile would most probably suit your needs better,

if im wrong and you only want to save the last entry (and overwrite the previos etc) then the registry option would be better... as far as i know there is no problems regarding admin privileges.

silly question: you want to save the values so when your app is closed they arent lost,and not that you want to save values while the app is running for use in that app session (as in sticking them in a variable)

good luck!
If somethings hard to do, its not worth doing - Homer Simpson
 
ADoozer, I want to let the user save some default values when using the application so that they don't have to reenter the same values when the application is relaunched.

thanx,
ik.
 
ok, this is just my opinion.

1. if you want to ONLY save the last entered values then use registry.

2. if you want to save values that are independant of users (eg comm port settings) then use registry.

3. if you want to save each and every users details use a text file. (obviously you will need to identify the user with this method)

the following is an alternate and may become complex.

4. finally, one that ive only started implementing today, is an autocomplete function that saves all info to a text file and is loaded in the form load event (ie a kind of intelisense)

hope this is of some help! If somethings hard to do, its not worth doing - Homer Simpson
 
You can write data to the end of your EXE file.
But there are a few drawbacks:
1) If you mess up (or PC hiccups) you'll corrupt the file
2) Anti-virus software will freak out
3) If your EXE is under system file protection of XP, the OS will not allow it.

It's probably best to do as ADoozer says.

Chip H.
 
You can write data in the EXE file. I have done this in C. But i will try in VB and let you know.
 
Data can be written in EXE file in the form of resources using update resource functions.

Check out the following.

BeginUpdateResource
UpdateResource
EndUpdateResource

But keep one obvious thing in mind. You cannot write data to your own EXE file which is being executed.
 
the saving and retriving via registry worked out well and it suited what I was trying to do because I was only storing small amount of data and only wanted to use one file to work with, the exe file, to simplify things.

thanks all,
ike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top