Results 1 to 10 of 10

Thread: Help with Date()

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    148

    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:
    1. Dim DailyLog As Integer
    2. Dim i As Integer
    3.  
    4. Private Sub Timer1_Timer()
    5. If i >= DailyLog Then
    6.         Label5.Caption = "Done with your daily limit!"
    7.         Exit Sub
    8. End If
    9.  
    10.  
    11. 'Code for sending message
    12. i = i + 1
    13.  
    14. Timer1.Enabled = False
    15. Timer2.Enabled = True
    16. 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.

  2. #2
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    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!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    148

    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?

  4. #4
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    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
    Zeegnahtuer?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    148

    Re: Help with Date()

    what is "blah"...what do I put there?

  6. #6
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Help with Date()

    Lol, ooops. Go into the ide and type GetSetting(

    Then wait for it, it will pop up a quick help box Get everything you need from there

    Oh, you actually need to type it for the quick help box
    Zeegnahtuer?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    148

    Re: Help with Date()

    ide?

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2005
    Posts
    148

    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

  9. #9
    Frenzied Member I_Love_My_Vans's Avatar
    Join Date
    Jan 2005
    Location
    In the PHP compiler
    Posts
    1,275

    Re: Help with Date()

    IDE Intergrated Design Environment

    I think

  10. #10
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    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
  •  



Click Here to Expand Forum to Full Width