Hi @Hahhuh456 ,
You can refer to the following code.
Imports System.IO
Imports System.Windows.Forms.DataVisualization.Charting
Public Class Form1
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Chart1.Series(0).ChartType = SeriesChartType.Line
Timer1.Interval = 1000
If Timer1.Enabled = False Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Chart1.Series(0).Points.Clear()
Dim fName = "C:\Yourfolder\Agriculture_Temp_Log.csv"
If File.Exists(fName) = True Then
Dim tmpstream As StreamReader = File.OpenText(fName)
Dim TextLine() As String = tmpstream.ReadToEnd().Split(Environment.NewLine)
For X = TextLine.Length - 12 To TextLine.Length - 2 'reading only the last 10 lines
Dim strline = TextLine(X).Split(",")
Chart1.Series(0).Points.AddXY(strline(1), CDbl(strline(2)))
Next
tmpstream.Close()
Else
MsgBox("file doesn't exist")
End If
End Sub
End Class
Best Regards.
Jiachen Li
----------
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.