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!

Logic Problem 1

Status
Not open for further replies.

kaylabear

Programmer
Oct 23, 2002
59
0
0
CA
Hello,

I'm trying to add Shareware to my application. I want to allow the user to try the program 5 times. I'm having trouble with the very first time the program is run.

For instance I write to the registry via SaveSetting() and set my variable to 1. Then every other time the program is run the variable = the variable + 1, until the variable = 5.

The problem is this, how do I stop the program from initializing the variable to 1 every other time the program is run.

Any and All input you can offer on this matter is greatly appreciated.

Thanks.
 
Hi,

You could just do a GetSetting() and check for an error(if the registry entry was not created yet). If the entry wasn't created yet, set it to 1, otherwise add 1 to it.
Basically remove the setting of the entry to 1 everytime you start the program.
Let me know if that doesn't answer your question.
 
Thanks Draven,

That really clears things up, but there is one other thing, where do I declare the variable that I am using, so that it isn't declared again and again?

thanks.
 
You're welcome kaylabear,

Maybe you could provide me with a little more detail. What exactly do you mean by 'declared again and again'? What I was referring to would mean that you would declare the variable once, perhaps in a form_load somewhere.
 
Hi

set it to 1 if and only if say a boolean variable is false
else if a boolean variable is true increment the value

Hope this helps.

Bye
Ravi
 
Private Sub Form_Load()
Dim started As Integer
started = CInt(GetSetting(Me.Name, "general", "startups", "0"))
Select Case started
Case Is < (5)
started = started + 1
SaveSetting Me.Name, &quot;general&quot;, &quot;startups&quot;, Str(started)
MsgBox (&quot;starts&quot; + Str(started))
Case Is >= (5)
MsgBox (&quot;Test period is over, please use the full version&quot;)
Unload Me
End Select
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top