如何在vb.net计时器中找到变量的第一个值?

时间:2010-09-02 03:08:03

标签: vb.net

我有这个问题:

我有一个vb.net类(visual studio 2010):

....
Private nowTime As String
....
Protected Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

  nowTime = My.Computer.Clock.LocalTime.ToLongTimeString

....

End Sub

在任何时间间隔内启用Timer后,如何获取“nowTime”字符串变量的第一个值?

提前致谢!

1 个答案:

答案 0 :(得分:1)

这样的事情应该有效。

....
Private nowTime As String
Private firstTime As String
Private isFirstTriggered As Boolean = False
....
Protected Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

  If Not isFirstTriggered Then
    firstTime = My.Computer.Clock.LocalTime.ToLongTimeString
    isFirstTriggered = True
  End If
  nowTime = My.Computer.Clock.LocalTime.ToLongTimeString

....

End Sub