Results 1 to 7 of 7

Thread: Disable Button???????

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224

    Question

    I have a program that I want to run only once a day. I want the user only to be allowed hit the command button once. Then at 5 oclock the next day I want the button to be enabled again. Does anyone have any ideas on how to approach. I know that I need a timer event but I have no idea on how to disable the command button until the next day.

    Any help is greatly appreciated.

    Thanks
    JK

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    Private Sub Timer1_Timer()
      Dim myTime As String
      myTime = Format(Now, "HH:MM:SS: AMPM")
      If myTime = "05:00:00 PM" Then cmdWhat.Enabled = True
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    And make sure to disable the command button after it's clicked.
    Code:
    Public Sub Command1_Click()
         Command1.Enabled = False
         'Do other stuff here.
    End Sub
    GL,
    D!m
    Dim

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Save the data of pressing the button either in a file or in the registry, on run of the prog, check if CurrentData - OldDate > 1 day (or 24 hours)
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Thanks a lot guys
    Have a good weekend
    JK

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    You to matey, that's what ya wanted?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  7. #7
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    jop
    you would still need a timer
    If you start the pgm at 4:58 the button is disabled
    (assuming it is always disabled from load)
    at 5:00,6,7,etc, the button will still be disabled.

    If, however, kanejone starts the program once a day and just wants the button enabled after 5:00 pm each day, then your method is the way to go as it doesn't include a timer with it's duty on the processor.

    Either way...the answer is there.



    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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