Hi,
I want to read file on timer tick ,i need to select file range from text box and then read those files. i am able read each file but,as i am ploting graph from those file i need a continues of each file ploting but the graph is directly showing last file graph when i add message box it is showing for each file and then going for next file. i want to the graph should be like movie on after another each file should roll on.
Thank you
What I have tried:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
For Each file1 As String In files
Chart1.Show()
Chart2.Show()
Chart3.Show()
Dim name As String = Path.GetFileNameWithoutExtension(file1)
Dim fileNo As Integer
If Integer.TryParse(name.Substring(1), fileNo) And fileNo >= TextBox1.Text AndAlso fileNo <= TextBox2.Text Then
Dim f1 As String
f1 = IO.File.ReadAllText("C:\Users\mks\Desktop\Newfolder\p" & fileNo & ".sp1")
TextBox3.Text = file1
Dim wFile, wFile1 As System.IO.FileStream
Dim byteData(), byteData1(), byteDatayp(), byteDatayn(), byteDatabp(), byteDatabn(), byteDatarp1(), byteDatarn1(), byteDatayp1(), byteDatayn1(), byteDatabp1(), byteDatabn1() As Byte
Dim rn, rp, yp, yn, bp, bn As String
Dim r As String = Regex.Replace(f1.ToString, "[^1-9Z-]", "")
r = Regex.Replace(r.ToString, "[-]", "0")
Dim elements() As String = Regex.Split(r, "Z")
For Each element In elements
Next
rp = elements(0)
rn = elements(1)
yp = elements(2)
yn = elements(3)
bp = elements(4)
bn = elements(5)
byteData = Encoding.ASCII.GetBytes(rp)
byteData1 = Encoding.ASCII.GetBytes(rn)
byteDatayp = Encoding.ASCII.GetBytes(yp)
byteDatayn = Encoding.ASCII.GetBytes(yn)
byteDatabp = Encoding.ASCII.GetBytes(yp)
byteDatabn = Encoding.ASCII.GetBytes(yn)
System.IO.File.WriteAllText("C:\Users\mks\Desktop\Newfolder\ro.mod", "")
wFile = New FileStream("C:\Users\mks\Desktop\Newfolder\ro.mod", FileMode.Append)
wFile.Write(byteData, 0, byteData.Length)
wFile.Close()
System.IO.File.WriteAllText("C:\Users\mks\Desktop\Newfolder\rs.mod", "")
wFile1 = New FileStream("C:\Users\mks\Desktop\Newfolder\rs.mod", FileMode.Append)
wFile1.Write(byteData1, 0, byteData1.Length)
wFile1.Close()
System.IO.File.WriteAllText("C:\Users\mks\Desktop\Newfolder\yo.mod", "")
wFile = New FileStream("C:\Users\mks\Desktop\Newfolder\yo.mod", FileMode.Append)
wFile.Write(byteDatayp, 0, byteDatayp.Length)
wFile.Close()
System.IO.File.WriteAllText("C:\Users\mks\Desktop\Newfolder\ys.mod", "")
wFile1 = New FileStream("C:\Users\mks\Desktop\Newfolder\ys.mod", FileMode.Append)
wFile1.Write(byteDatayn, 0, byteDatayn.Length)
wFile1.Close()
System.IO.File.WriteAllText("C:\Users\mks\Desktop\Newfolder\bo.mod", "")
wFile = New FileStream("C:\Users\mks\Desktop\Newfolder\bo.mod", FileMode.Append)
wFile.Write(byteDatabp, 0, byteDatabp.Length)
wFile.Close()
System.IO.File.WriteAllText("C:\Users\mks\Desktop\Newfolder\bs.mod", "")
wFile1 = New FileStream("C:\Users\mks\Desktop\Newfolder\bs.mod", FileMode.Append)
wFile1.Write(byteDatabn, 0, byteDatabn.Length)
wFile1.Close()
File.Delete("C:\Users\mks\Desktop\Newfolder\ro1.mod")
File.Delete("C:\Users\mks\Desktop\Newfolder\yo1.mod")
File.Delete("C:\Users\mks\Desktop\Newfolder\bo1.mod")
File.Delete("C:\Users\mks\Desktop\Newfolder\rs1.mod")
File.Delete("C:\Users\mks\Desktop\Newfolder\ys1.mod")
File.Delete("C:\Users\mks\Desktop\Newfolder\bs1.mod")
For i As Integer = 0 To f1.Length - 1 Step 1
If i Mod 1 = 0 Then
End If
Try
Dim rp1 As String = i / 10 & " " & rp.Substring(i, 1) & Environment.NewLine
Dim rn1 As String = i / 10 & " -" & rn.Substring(i, 1) & Environment.NewLine
Dim yp1 As String = i / 10 & " " & yp.Substring(i, 1) & Environment.NewLine
Dim yn1 As String = i / 10 & " -" & yn.Substring(i, 1) & Environment.NewLine
Dim bp1 As String = i / 10 & " " & bp.Substring(i, 1) & Environment.NewLine
Dim bn1 As String = i / 10 & " -" & bn.Substring(i, 1) & Environment.NewLine
byteDatarp1 = Encoding.ASCII.GetBytes(rp1)
byteDatarn1 = Encoding.ASCII.GetBytes(rn1)
byteDatayp1 = Encoding.ASCII.GetBytes(yp1)
byteDatayn1 = Encoding.ASCII.GetBytes(yn1)
byteDatabp1 = Encoding.ASCII.GetBytes(bp1)
byteDatabn1 = Encoding.ASCII.GetBytes(bn1)
wFile = New FileStream("C:\Users\mks\Desktop\Newfolder\ro1.mod", FileMode.Append)
wFile.Write(byteDatarp1, 0, byteDatarp1.Length)
wFile.Close()
wFile1 = New FileStream("C:\Users\mks\Desktop\Newfolder\rs1.mod", FileMode.Append)
wFile1.Write(byteDatarn1, 0, byteDatarn1.Length)
wFile1.Close()
wFile = New FileStream("C:\Users\mks\Desktop\Newfolder\yo1.mod", FileMode.Append)
wFile.Write(byteDatayp1, 0, byteDatayp1.Length)
wFile.Close()
wFile1 = New FileStream("C:\Users\mks\Desktop\Newfolder\ys1.mod", FileMode.Append)
wFile1.Write(byteDatayn1, 0, byteDatayn1.Length)
wFile1.Close()
wFile = New FileStream("C:\Users\mks\Desktop\Newfolder\bo1.mod", FileMode.Append)
wFile.Write(byteDatabp1, 0, byteDatabp1.Length)
wFile.Close()
wFile1 = New FileStream("C:\Users\mks\Desktop\Newfolder\bs1.mod", FileMode.Append)
wFile1.Write(byteDatabn1, 0, byteDatabn1.Length)
wFile1.Close()
Catch ex As ArgumentOutOfRangeException
Exit For
Finally
End Try
Next
Chart1.ChartAreas(0).AxisX.ScaleView.Size = 100
For Each line As String In IO.File.ReadAllLines("C:\Users\mks\Desktop\Newfolder\ro1.mod")
Dim points() As Double = Array.ConvertAll(line.Split(" "c), Function(s) CDbl(s))
Chart1.Series(0).Points.AddXY(points(0), points(1))
Next
For Each line As String In IO.File.ReadAllLines("C:\Users\mks\Desktop\Newfolder\rs1.mod")
Dim points() As Double = Array.ConvertAll(line.Split(" "c), Function(s) CDbl(s))
Chart1.Series(0).Points.AddXY(points(0), points(1))
Next
Chart2.ChartAreas(0).AxisX.ScaleView.Size = 100
For Each line As String In IO.File.ReadAllLines("C:\Users\mks\Desktop\Newfolder\ro1.mod")
Dim points() As Double = Array.ConvertAll(line.Split(" "c), Function(s) CDbl(s))
Chart2.Series(0).Points.AddXY(points(0), points(1))
Next
For Each line As String In IO.File.ReadAllLines("C:\Users\mks\Desktop\Newfolder\rs1.mod")
Dim points() As Double = Array.ConvertAll(line.Split(" "c), Function(s) CDbl(s))
Chart2.Series(0).Points.AddXY(points(0), points(1))
Next
Chart3.ChartAreas(0).AxisX.ScaleView.Size = 100
For Each line As String In IO.File.ReadAllLines("C:\Users\mks\Desktop\Newfolder\ro1.mod")
Dim points() As Double = Array.ConvertAll(line.Split(" "c), Function(s) CDbl(s))
Chart3.Series(0).Points.AddXY(points(0), points(1))
Next
For Each line As String In IO.File.ReadAllLines("C:\Users\mks\Desktop\Newfolder\rs1.mod")
Dim points() As Double = Array.ConvertAll(line.Split(" "c), Function(s) CDbl(s))
Chart3.Series(0).Points.AddXY(points(0), points(1))
Next
MsgBox("FIlE HAS BEEN PROCEESED")
End If
Timer1.Stop()
Next
End Sub
Private Sub CmdStart_Click_Click(sender As Object, e As EventArgs) Handles CmdStart_Click.Click
Timer1.Interval = 10000
Timer1.Start()
End Sub