|
-
May 18th, 2010, 02:11 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Form Opening
How can i know how many times the user open my form and how can i know if the user open it for the first time ??????
-
May 18th, 2010, 02:19 PM
#2
Re: Form Opening
You have to implement a counter mechanism that will increment each time it is loaded (Load event) but you have to save it somewhere so it remember is when the application is closed. Maybe in the registry or in a file.
-
May 18th, 2010, 02:26 PM
#3
Thread Starter
Addicted Member
Re: Form Opening
 Originally Posted by baja_yu
You have to implement a counter mechanism that will increment each time it is loaded (Load event) but you have to save it somewhere so it remember is when the application is closed. Maybe in the registry or in a file.
How can i save it in registry or a hidden file that is save the value where the program is
-
May 18th, 2010, 02:39 PM
#4
Re: Form Opening
An example:
Code:
Option Explicit
Private myCount As Integer
Private Sub Form_Load()
myCount = myCount + 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSetting appname:="MyApp", section:="TimesLoaded", _
Key:="MainForm", setting:=myCount
End Sub
'to retrieve the value:
'GetSetting appname := "MyApp", section := "TimesLoaded", _
key := "Mainform", default := 0
-
May 18th, 2010, 02:56 PM
#5
Thread Starter
Addicted Member
Re: Form Opening
 Originally Posted by vbfbryce
An example:
Code:
Option Explicit
Private myCount As Integer
Private Sub Form_Load()
myCount = myCount + 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSetting appname:="MyApp", section:="TimesLoaded", _
Key:="MainForm", setting:=myCount
End Sub
'to retrieve the value:
GetSetting appname := "MyApp", section := "TimesLoaded", _
key := "Mainform", default := 0
i paste it and it's not work about getsetting where should put it i put it in the form load
-
May 18th, 2010, 03:00 PM
#6
-
May 18th, 2010, 03:40 PM
#7
Thread Starter
Addicted Member
Re: Form Opening
it's gonna be better if i have just the code
-
May 18th, 2010, 04:14 PM
#8
Re: Form Opening
But you'll learn more if you actually do some work yourself.
-
May 18th, 2010, 04:16 PM
#9
Re: Form Opening
Something to keep in mind when using the registry; Admin and standard users will get different values.
to hide a file:
Hide a file
App.Path & ":myFile.dat"
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
May 18th, 2010, 04:23 PM
#10
Thread Starter
Addicted Member
Re: Form Opening
 Originally Posted by isnoend07
Something to keep in mind when using the registry; Admin and standard users will get different values.
to hide a file:
Hide a file
App.Path & ":myFile.dat
i never see something like that btw this code not working
invalid property assignment
Last edited by Pc Monk; May 18th, 2010 at 04:32 PM.
-
May 18th, 2010, 04:45 PM
#11
Re: Form Opening
 Originally Posted by Pc Monk
i never see something like that btw this code not working
invalid property assignment
Code:
Dim fname As String
Dim uses As Integer
uses = 1
fname = App.Path & ":mydata.dat"
Open fname For Output As #1
Print #1, uses
Close #1
Open the hidden file
Dim fname As String
Dim uses As String
fname = App.Path & ":mydata.dat"
Open fname For Input As #1
Line Input #1, uses
Close #1
MsgBox uses
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
May 19th, 2010, 02:07 AM
#12
Thread Starter
Addicted Member
Re: Form Opening
 Originally Posted by isnoend07
Code:
Dim fname As String
Dim uses As Integer
uses = 1
fname = App.Path & ":mydata.dat"
Open fname For Output As #1
Print #1, uses
Close #1
Open the hidden file
Dim fname As String
Dim uses As String
fname = App.Path & ":mydata.dat"
Open fname For Input As #1
Line Input #1, uses
Close #1
MsgBox uses
Thank You for the code
now how can i hide that file that i make it ???
-
May 19th, 2010, 11:15 AM
#13
Re: Form Opening
 Originally Posted by Pc Monk
Thank You for the code
now how can i hide that file that i make it ???
After you run the code try to find the file
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
May 19th, 2010, 11:53 AM
#14
Re: Form Opening
This may help on what you are trying to do;
Code:
Const mMaxUses As Integer = 5
Private Sub Command1_Click() 'save
Dim fname As String
Dim uses As Integer
uses = 1
fname = App.Path & ":xp32sys.sys"
Open fname For Output As #1
Print #1, uses
Close #1
End Sub
Private Sub Command2_Click() 'open
Dim fname As String
Dim uses As String
fname = App.Path & ":xp32sys.sys"
Open fname For Input As #1
Line Input #1, uses
Close #1
If Val(uses) >= mMaxUses Then
MsgBox "You used the software the maximun times"
Exit Sub
End If
If Val(uses) <> 0 Then
AddAUse uses
End If
End Sub
Sub AddAUse(uses)
Dim fname As String
Dim usesleft As Integer
uses = uses + 1
fname = App.Path & ":xp32sys.sys"
Open fname For Output As #1
Print #1, uses
Close #1
usesleft = mMaxUses - uses
Me.Caption = "demo and uses left: " & usesleft
MsgBox uses
End Sub
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
May 19th, 2010, 12:10 PM
#15
Thread Starter
Addicted Member
Re: Form Opening
That's what i need
thank's alot
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
|