2015-12-24 3 views
-1

вот пример:Visual Basic Как проверить, изменилась ли переменная за 5 минут?

Dim Cchanges As Integer 

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick 

    If 'some kind a solution here' Then 
     MsgBox("there is no changes made in 5 minutes") 
    End If 
End Sub 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
    Label1.Text = Cchanges 
End Sub 

и любые другие решения будут appraciated.

+0

Вам нужна другая переменная, которая хранит значение Cchanges при запуске таймера. –

ответ

-1

Это должно дать вам то, что вам нужно:

Private timer As New Timer(TimerTick, Nothing, TimeSpan.Zero, New TimeSpan(0, 0, 0, 1)) 
Private lastMinute As Integer = 1 

Private Sub TimerTick(state As Object) 
    Dim minute = DateTime.Now.Minutes 
    If minute <> lastMinute AndAlso minute Mod 5 = 0 Then 

     Select Case (String.Compare(txtOldValue.text, txtNewValue.text) 
      Case < 0 
       MsgBox("Your old value is smaller than your new value or is null.") 
      Case = 0 
       MsgBox("The values are equal") 
      Case > 0 
       MsgBox("Your new value is smaller than your old value or is null." 
     End Select 
     lastMinute = minute 

    End If 
End Sub 
Смежные вопросы