I'm working on a program for reading a txt file. the file is read and its data are sent to the viewers with an indeterminate cycle every minute.
I wanted to replace the sleep with a timer. I tried the same procedure under timers instead of under button1 but it does not work. how can I proceed with the change.
Public Class Form1
Dim disco1 As System.IO.File
Dim leggi1 As System.IO.Strea mReader
Dim ms As Integer = 60000
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Me.Size = Screen.PrimaryS creen.WorkingAr ea.Size
Me.Location = Screen.PrimaryS creen.WorkingAr ea.Location
End Sub
Private Sub Button1_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button1.Click
Button1.BackCol or = Color.Red
Dim riga1 As String
Dim i As Integer
Do
leggi1 = disco1.OpenText ("e:\rgb100.txt ")
For i = 1 To 60
i = i + 1
riga1 = leggi1.ReadLine ()
TextBox1.Text = riga1
ListBox1.Items. Add(riga1)
Application.DoE vents()
System.Threadin g.Thread.Sleep( ms)
Next i
Loop
End Sub
End Class
I wanted to replace the sleep with a timer. I tried the same procedure under timers instead of under button1 but it does not work. how can I proceed with the change.
Public Class Form1
Dim disco1 As System.IO.File
Dim leggi1 As System.IO.Strea mReader
Dim ms As Integer = 60000
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Me.Size = Screen.PrimaryS creen.WorkingAr ea.Size
Me.Location = Screen.PrimaryS creen.WorkingAr ea.Location
End Sub
Private Sub Button1_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button1.Click
Button1.BackCol or = Color.Red
Dim riga1 As String
Dim i As Integer
Do
leggi1 = disco1.OpenText ("e:\rgb100.txt ")
For i = 1 To 60
i = i + 1
riga1 = leggi1.ReadLine ()
TextBox1.Text = riga1
ListBox1.Items. Add(riga1)
Application.DoE vents()
System.Threadin g.Thread.Sleep( ms)
Next i
Loop
End Sub
End Class
Comment