|
-
Feb 28th, 2015, 08:40 AM
#1
Thread Starter
New Member
Enable button using dateTime.Add(1)
So yeah basically what i'm trying to do is to enable a disabled button,after 24 hours starting from the time it has been disabled!!!
Right now my code is this:
Code:
Private Sub FlatButton1_Click(sender As Object, e As EventArgs) Handles FlatButton1.Click
Static ctClicks As Integer = 0
ctClicks += 1
If ctClicks = 10 Then FlatButton1.Enabled = False
Using wc As New WebClient
Dim response As String = wc.DownloadString("http://website.com/text.php")
FlatTextBox1.Text = response
End Using
End Sub
I was thinking of doing something like this:
If DateTime.Today.AddDays(1)
Then
FlatButton1.Enabled = True
End If
-
Feb 28th, 2015, 09:04 AM
#2
Re: Enable button using dateTime.Add(1)
 Originally Posted by elx00r
I was thinking of doing something like this:
If DateTime.Today.AddDays(1)
Then
FlatButton1.Enabled = True
End If
That would not make sense. `If` statements evaluate a Boolean expression and AddDays does not return a Boolean value. What you would need to do is Start a Timer and set its Interval to the equivalent of 1 day. The Tick event will then be raised and you can enable the Button. If the application may be closed and restarted in between then you need to save the date and time somewhere external. You can then read that at startup and configure a Timer appropriately.
-
Feb 28th, 2015, 09:12 AM
#3
Thread Starter
New Member
Re: Enable button using dateTime.Add(1)
i was giving an idea of what i want to do...so yes the application will be closed and reopened on the same,that's why i dont know how to deal with this. How do i save that Date,time and read them on startup?! Is there any code around? Its been like 3-4 days i've been looking to solve this thing. Furthermore i dont use database!!!!! Thankyou
-
Mar 1st, 2015, 03:20 AM
#4
Re: Enable button using dateTime.Add(1)
I think you've already been told how to save data externally in your other thread but you complained that that wasn't what you wanted to know. This is why they were telling you that in the first place.
Tags for this Thread
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
|