定时器和更新标签文本

时间:2014-06-05 18:05:14

标签: vb.net timer

我试图让应用程序显示什么时候有“新”的东西。所以我制作了Label1和Timer。我希望每个secound检查status.txt文本中是否为0以显示任何内容,如果其中1为显示来自text.txt的文本。这是迄今为止的尝试:

Public Class Form1
    Dim client As WebClient = New WebClient()
    Dim status As String = client.DownloadString("http://force-play.com/launcher/status.txt")
    Dim information As String = client.DownloadString("http://force-play.com/launcher/text.txt")

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
        Timer1.Interval = 1000
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If status = 0 Then
            Label1.Text = "No New Info"
        End If
        If status = 1 Then
            Label1.Text = information
        End If
    End Sub
End Class

1 个答案:

答案 0 :(得分:1)

尝试在status方法的开头设置Timer1_Tick字符串。

相关问题