|
-
Jan 7th, 2006, 04:25 PM
#1
Thread Starter
Addicted Member
Help with Date()
I'm trying to create a program that will only let the user do a certain amount of tasks per 24 hours. The program is very basic and looks kinda like this:
VB Code:
Dim DailyLog As Integer
Dim i As Integer
Private Sub Timer1_Timer()
If i >= DailyLog Then
Label5.Caption = "Done with your daily limit!"
Exit Sub
End If
'Code for sending message
i = i + 1
Timer1.Enabled = False
Timer2.Enabled = True
End Sub
Now, when you look at this, you might think that the i = i + 1 wont work, but I"ve left out a lot of code...in my program it does work.
Here's my question:
If the user closes out the program and starts it again, the program will say that i = 0, but what I want it to do is retain its last value. That value should then reset after 24 hours. Can this be done with the date function.
-
Jan 7th, 2006, 04:40 PM
#2
Re: Help with Date()
Why don't you use the registry?
Check for time the user wants run the code, if the last run was 24 hours/ or the day before.
and if you run the code, save the exer time in te registry!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Jan 7th, 2006, 04:48 PM
#3
Thread Starter
Addicted Member
Re: Help with Date()
oh, thats a good idea. Do you have a link to show me how to write it to the registry? Also, will this work during debugging mode or just when the program is run under the .exe?
-
Jan 7th, 2006, 04:51 PM
#4
Re: Help with Date()
It will work in both, using the registry is easy.. do the following -
To Save a seeting do this...
SaveSetting("PROGRAMNAME", "SUBSECTION", "BLAH", value.to.save.goes.here)
To get that setting doe this...
GetSetting("PROGRAMNAME", "SUBSECTION", "BLAH")
Simple
-
Jan 7th, 2006, 05:37 PM
#5
Thread Starter
Addicted Member
Re: Help with Date()
what is "blah"...what do I put there?
-
Jan 7th, 2006, 05:39 PM
#6
-
Jan 7th, 2006, 05:48 PM
#7
Thread Starter
Addicted Member
-
Jan 7th, 2006, 06:34 PM
#8
Thread Starter
Addicted Member
Re: Help with Date()
ok, I figured out how to save and get from the registry
http://www.vbforums.com/showthread.php?t=232113
but how do I reset the value after 24 hours? I guess that's where I'm lost
-
Jan 7th, 2006, 07:23 PM
#9
Re: Help with Date()
IDE Intergrated Design Environment
I think
-
Jan 8th, 2006, 01:18 PM
#10
Re: Help with Date()
You don't have to reset anything, just check the difference between the stored value (TheOldDate) and the actual Date value, if the difference is OK than do the code, and else do whatever!
The only thing YOU have to decide is: is a difference of 24 hours needed (always another date!)or the turn of the date(maybe less then an hour).
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
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
|