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
Re: Enable button using dateTime.Add(1)
Quote:
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.
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
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.