|
-
May 21st, 2006, 06:51 PM
#1
Thread Starter
Member
[RESOLVED] load limited times
Hi! i was wondering if i can put a limit on how many times my main form is loaded. after it has been loaded 10 or how many every times i would like it to call this form.
Thanks
VB Code:
Private Sub Command1_Click()
If Text1.Text = "11" Or Text2.Text = "11" Then
'Save the text inside the textboxes
SaveSetting "MyApp", "General", "User", Text1.Text
SaveSetting "MyApp", "General", "User2", Text2.Text
MsgBox "Thanks for Registering!", vbExclamation, "Register"
'Unload Form
Unload Me
Else
MsgBox "Arrr... Wrong. Try again.", vbInformation, "Register"
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
'Get rid of all text
Text2.Text = ""
Text1.Text = ""
SaveSetting "MyApp", "General", "User2", Text2.Text
SaveSetting "MyApp", "General", "User", Text1.Text
'Reset the Register
Hidden.Text = "d"
SaveSetting "MyApp", "General", "Reset", Hidden.Text
'Unload form
Unload Me
End Sub
Private Sub Command3_Click()
MsgBox "Sample on How to Make a Registration Form For Your Programme" & _
vbCrLf & "By Reynard Chan, Age 12" & _
vbCrLf & "Made with Visual Basic 6" & _
vbCrLf & "Located at: www.planet-source-code.com/vb/" & _
vbCrLf & "Please send comments at that site or: [email]@dbzfreak.cjb.net[/email]", vbInformation, "Register Sample"
End Sub
Private Sub Form_Load()
'Check if reseted
Hidden.Text = GetSetting("MyApp", "General", "Reset", Hidden.Text)
'Check if registered or not.
Text2.Text = GetSetting("MyApp", "General", "User2", Text2.Text)
Text1.Text = GetSetting("MyApp", "General", "User", Text1.Text)
If Text1.Text = "Reynard Chan" Or Text2.Text = "ED23498-28" Then
MsgBox "You've registered the programme! Woopee! ", vbInformation, "Registered!"
Else
MsgBox "Please register this programme now", vbExclamation, "Unregistered"
End If
End Sub
Last edited by bammoeller; May 23rd, 2006 at 11:34 AM.
-
May 21st, 2006, 07:38 PM
#2
Re: load limited times
Do you mean you want to limit the number of times your program can be run?
-
May 21st, 2006, 08:03 PM
#3
Thread Starter
Member
Re: load limited times
Correct after limit is up i want it to load the form above
Thanks
-
May 21st, 2006, 08:24 PM
#4
Re: load limited times
Create a Sub Main in a code module and make Sub Main the Startup Object. Then every time the program is run use GetSetting and SaveSetting to keep a count of the number of runs and if it's > 10 the load your alternate form from Sub Main, otherwise load your main form from Sub Main.
To guard against someone using RegEdit to decrement the run count, you should store the value encrypted and also have code that says "If there is no registry entry (because it's been deleted) load the alternate form
-
May 21st, 2006, 08:34 PM
#5
Thread Starter
Member
Re: load limited times
if you have the time could you give me an example of what you are saying thanks martin
-
May 21st, 2006, 08:54 PM
#6
Thread Starter
Member
Re: load limited times
I guess this will work Thanks
VB Code:
retvalue = GetSetting("A", "0", "RunCount")
Activate$ = Val(retvalue) + 1
SaveSetting "A", "0", "RunCount",Activate$
If Activate$ < 20 Then
End If
If Activate$ > 19 Then
Call Command1_Click
End If
-
May 21st, 2006, 09:03 PM
#7
Re: load limited times
I would change your code a little as shown. The check for zero handles the case where someone has deleted the Registry entry.
VB Code:
Dim retvalue As Integer
retvalue = GetSetting("A", "0", "RunCount",[HL="#FFFF80"]0[/HL])
Activate$ = retvalue + 1
SaveSetting "A", "0", "RunCount",Activate$
If Activate$ < 20 Then
End If
If Activate$ > 19 [HL="#FFFF80"]Or Activate$ = 0[/HL] Then
Call Command1_Click
End If
-
May 21st, 2006, 09:53 PM
#8
Thread Starter
Member
Re: load limited times
Thanks for the tip! after the limit is reached it calls this source
VB Code:
Private Sub Command1_Click()
If Text1.Text = "username" Or Text2.Text = "activation code" Then
'Save the text inside the textboxes
SaveSetting "MyApp", "General", "User", Text1.Text
SaveSetting "MyApp", "General", "User2", Text2.Text
MsgBox "Thanks for Registering!", vbExclamation, "Register"
'Unload Form
Unload Me
Else
MsgBox "Arrr... Wrong. Try again.", vbInformation, "Register"
Text1.SetFocus
End If
End Sub
how can i make it to where you only have to register it one time? The issue is the register this product form will come up everytime the software is loaded, even after the software has been registered. could you enlightened on how i can get around this?
Thanks for your fast replys
-
May 21st, 2006, 10:15 PM
#9
Re: load limited times
VB Code:
Private Sub Command1_Click()
Dim strRegistered As String
strRegistered = GetSetting("MyApp", "General","Registered","No"
If strRegistered = "Yes" Then
Exit Sub
End If
SaveSetting("MyApp", "General","Registered","Yes"
If Text1.Text = "username" Or Text2.Text = "activation code" Then
'Save the text inside the textboxes
SaveSetting "MyApp", "General", "User", Text1.Text
SaveSetting "MyApp", "General", "User2", Text2.Text
MsgBox "Thanks for Registering!", vbExclamation, "Register"
'Unload Form
Unload Me
Else
MsgBox "Arrr... Wrong. Try again.", vbInformation, "Register"
Text1.SetFocus
End If
End Sub
-
May 23rd, 2006, 10:37 AM
#10
Thread Starter
Member
Re: load limited times
Thanks for the help! wonder why it errors? Thanks
VB Code:
Dim strRegistered As String
' this line strRegistered = GetSetting("MyApp", "General","Registered","No"
If strRegistered = "Yes" Then
Exit Sub
End If
' this line SaveSetting("MyApp", "General","Registered","Yes"
If Text1.Text = "username" Or Text2.Text = "activation code" Then
'Save the text inside the textboxes
SaveSetting "MyApp", "General", "User", Text1.Text
SaveSetting "MyApp", "General", "User2", Text2.Text
MsgBox "Thanks for Registering!", vbExclamation, "Register"
'Unload Form
Unload Me
Else
MsgBox "Arrr... Wrong. Try again.", vbInformation, "Register"
Text1.SetFocus
-
May 23rd, 2006, 10:39 AM
#11
Re: load limited times
 Originally Posted by bammoeller
Thanks for the help! wonder why it errors?
What is the error and on what line is it occuring?
-
May 23rd, 2006, 10:41 AM
#12
Thread Starter
Member
Re: load limited times
' this line SaveSetting("MyApp", "General","Registered","Yes"
' this line strRegistered = GetSetting("MyApp", "General","Registered","No"
The lines are red
Thanks for the super fast responce hack
-
May 23rd, 2006, 10:48 AM
#13
Re: load limited times
Are you talking about the lines that you have commented out?
-
May 23rd, 2006, 10:54 AM
#14
Re: load limited times
Somehow the closing parenthesis ")" at the end of each line was left off so it should be
VB Code:
Private Sub Command1_Click()
Dim strRegistered As String
strRegistered = GetSetting("MyApp", "General","Registered","No"[HL="#FFFF80"])[/HL]
If strRegistered = "Yes" Then
Exit Sub
End If
SaveSetting("MyApp", "General","Registered","Yes"[HL="#FFFF80"])[/HL]
If Text1.Text = "username" Or Text2.Text = "activation code" Then
'Save the text inside the textboxes
SaveSetting "MyApp", "General", "User", Text1.Text
SaveSetting "MyApp", "General", "User2", Text2.Text
MsgBox "Thanks for Registering!", vbExclamation, "Register"
'Unload Form
Unload Me
Else
MsgBox "Arrr... Wrong. Try again.", vbInformation, "Register"
Text1.SetFocus
End If
End Sub
-
May 23rd, 2006, 10:57 AM
#15
Thread Starter
Member
Re: load limited times
oh ok thanks Martin and hack
-
May 23rd, 2006, 11:14 AM
#16
Thread Starter
Member
Re: load limited times
VB Code:
Dim strRegistered As String
strRegistered = GetSetting("MyApp", "General","Registered","No")
If strRegistered = "Yes" Then
Exit Sub
End If
[COLOR=Red]SaveSetting("MyApp", "General","Registered","Yes")
[/COLOR]
If Text1.Text = "username" Or Text2.Text = "activation code" Then
'Save the text inside the textboxes
SaveSetting "MyApp", "General", "User", Text1.Text
SaveSetting "MyApp", "General", "User2", Text2.Text
MsgBox "Thanks for Registering!", vbExclamation, "Register"
'Unload Form
Unload Me
Else
MsgBox "Arrr... Wrong. Try again.", vbInformation, "Register"
Text1.SetFocus
End If
I dunno its still fire red lol
-
May 23rd, 2006, 11:26 AM
#17
Re: load limited times
GetSetting requires parentheses, SaveSetting does not. This should work (and display) just fine
VB Code:
SaveSetting "MyApp", "General", "Registered", "Yes"
-
May 23rd, 2006, 11:28 AM
#18
Thread Starter
Member
-
May 23rd, 2006, 12:04 PM
#19
Thread Starter
Member
Re: load limited times
Shucks now it does absolutely nothing when i click on the command button
VB Code:
Dim strRegistered As String
strRegistered = GetSetting("MyApp", "General", "Registered", "No")
If strRegistered = "Yes" Then
Exit Sub
End If
SaveSetting "MyApp", "General", "Registered", "Yes"
If Text1.Text = "1" Or Text2.Text = "1" Then
'Save the text inside the textboxes
SaveSetting "MyApp", "General", "User", Text1.Text
SaveSetting "MyApp", "General", "User2", Text2.Text
MsgBox "Thanks for Registering!", vbExclamation, "Register"
'Unload Form
Unload Me
Else
MsgBox "Arrr... Wrong. Try again.", vbInformation, "Register"
Text1.SetFocus
End If
-
May 23rd, 2006, 12:20 PM
#20
Re: [RESOLVED] load limited times
Put a break on it and step through to see what it is doing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|