hi there vb5prgrmr your reply offers a lot of insight, however I am a little unsure of what ((Appname as string), (Section as string), (Key as string), (Default as string)), each of these parameters means and how I go about using these options.
I am greatful for your help as my version of Visual Basic does not have working help files.
Basically, it can be viewed as a directory structure (its not I know but it is a good analogy). Where...
GetSetting
Appname is the root directory
Section is a sub folder
Key is a descriptive File (or another sub folder if you wish)
and...
Default is the contents of the file and if empty this is the default value
SaveSetting
Appname is the root directory to be created if necessary
Section is a subfolder to be created if necessary
Key is a descriptive file name to be created if necessary
and...
Setting is the contents you want to save in the file
So lets say you want to store a user name and password in the registry (if you do this I would suggest some type of encryption), you would do something like...
Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
Hi, everyone's tips are very insightfull, but I'm still having trouble understanding how it all comes together.
I have an example listed below, basically when the program starts, GetSetting is called to determine the value of trys. If this is the very first time the program is run than trys will not exist yet and an error will occur, so at this point the variable trys will be created and assigned a value of zero.
Next the value of trys will be incremented by one and SaveSetting will be called to save the value of trys.
PUESDO CODE:
Sub Form Load()
GetSetting(trys), the value of trys
OnError: Undefined Variable Type, trys
{
Dim trys as byte
trys = 0
}
trys = trys + 1
SaveSetting(trys), the value of trys
[tt] Dim NoTrys As Byte
NoTrys = Val(GetSetting(App.EXEName, "Number Of Trys", "Count", "0")
NoTrys = NoTrys + 1 If NoTrys > maxamount Then
MsgBox "You have exceded the number of times that this program can be run!", vbOKOnly + vbCritical, "Program Will Now End!" End End If
SaveSetting App.EXEName, "Number Of Trys", "Count", Trim(Str(NoTrys))
Yes Thank you vb5prgrmr, but how do I handle the ERROR. Because when trys or noTrys is called the first time it can't yet exist and if this is the case an error will occur.
It is only at this point that I want to create noTrys.
Otherwise every other time the program runs I want to increment noTrys without having to re-create it every time.
You are going to have to declare a variable to recieve the value from getsetting or use a hidden control to store the value. If you have not yet declared a variable and then try to place that value in a variable that has not yet been declared you are going to run into problems. VB 6.0 does not let you do conditional declarations (VB.NET Does as do some other languages), you must declare the variable to use it or you will recieve errors. (Actually you could turn off Option Explicit by deleting it from the top of the form but this is definitly going to get you into more trouble than it is worth.)
So in short you are going to have to declare trys(notrys in my example as you can see in my example) to be able to use it without having any errors.
I would suggest at this time to surf over to borders.com or another web site and look for a visual basic 6.0 beginners book.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.