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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie question, Where is best to store a couple of text strings?

Status
Not open for further replies.

BriCorbin

Technical User
Jan 28, 2004
3
0
0
NZ
Hi all,

I am very new to VB and programming in general so please go easy on me if this is a dumb question ;-)
I have battled my way thru a user interface and made my very first program work! (yay for me) It was tough at times but looking at other peoples code and this group helped a lot.
The thing works OK but now I relalse that I want the program to remember some of the stuff the user is typing in. The info comes via text and combo boxs. Some of these items allow the user to add thier own string in the combo/text box which needs to be there next time they run the program. there will be 5 users running the program on a network so wherever the info is stored it will need to be read & written by multiple people.
Is there some internal place that will remember these in VB? should I look at putting the strings into a text file or a database?
What is going to be easiest for a real begineer?
Some pointers on where to look for an example would be great.
I already have my own setup form in the program so I could add a text box and browse button to set the location on the network to a text/database file?

Thanks for any help
Brian
 
The best (and easiest) way to permanently store strings is in the reggistry. You save a setting (or string, in your case) with this:

SaveSetting AppName as String, Section as String, Key as String, Setting as String


EX: SaveSetting "New Program", "Strings", "String1", String1

To get a setting:

GetSetting(AppName as String, Section as String, Key as String)

EX: String1 = GetSetting("New Program", "Strings", "String1")

Remember that getting a setting before it has been saved produces an error, so make sure you save a blank setting for each before you run the program the first time. I use an install program, but there may be a check to see if a registry path exists or not. Unfortunately, I'm a newbie too. ;) Good luck.
 
GetSetting(txtAppName, txtSection, txtKey, "No Setting Found")

Where the final parameter is a default value that is set if no setting is found
 
You say <there will be 5 users running the program on a network so wherever the info is stored it will need to be read & written by multiple people.>

If they each need to store their own info (5 separate sets) then registry (as above) would work. If the info is common to all users then either:

1. Use a text file on the server, but you'll need to decide how to lock the file for editing.

2. Use a database. A simple mdb file accessed by ADO sounds fine for this. There is a good ADO programming sample in VBHelp

Registry is generally used for data specific to one machine or user. The simplistic use of GetSetting & SaveSetting is shared by all users of one program on the one machine

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top