I'm trying to make a button that when pressed for a short while will close the form but when pressed for a long time e.g. 5s the form's process will be killed.
I'm trying to achieve this with a timer.
Private Sub CloseLongTimer_Tick(sender As Object, e As EventArgs) Handles CloseLongTimer.Tick
Dim SetTime As Integer = 0
SetTime = SetTime + 1
If SetTime < 500 Then
Me.Close()
ElseIf SetTime > 499 And SetTime < 1001 Then
System.Environment.Exit(1)
ElseIf SetTime > 1000 Then
CloseLongTimer.Stop()
End If
End Sub
Private Sub CloseButton_MouseDown(sender As Object, e As EventArgs) Handles CloseButton.MouseDown
CloseLongTimer.Start()
End Sub
Any help? I think it's a problem in logic. Thanks.