Imports System.IO
Imports System.Math
Public Class Form1
Public namaFile As String = "C:\sementara.txt"
Public data1(100) As Double
Public jumData As Short
Private i As Short = 0
Private k As Integer = 0
Private threadProgress As System.Threading.Thread
Dim InputNamaFile As StreamWriter
Private Sub OkToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OkToolStripMenuItem.Click
InputNamaFile = New StreamWriter(namaFile, False)
jumData = 100
InputNamaFile.Close()
Timer1.Enabled = True
End Sub
Public Sub saveFile1()
InputNamaFile = New StreamWriter(namaFile, True)
Dim a As String
For i = 0 To jumData - 1
a = CStr(data1(i)) & ";" & CStr(data1(i))
InputNamaFile.Write(a & vbNewLine)
Next
InputNamaFile.Close()
OnFinished()
End Sub
Private Sub OnFinished()
threadProgress = Nothing
End Sub
Private Sub ProcesDong1()
threadProgress = New System.Threading.Thread(AddressOf saveFile1)
'threadProgress.Name = "Background Thread"
'threadProgress.IsBackground = True
threadProgress.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = k
data1(i) = k
If i <= jumData - 1 Then
data1(i) = k
ElseIf i = jumData Then
ProcesDong1()
'saveFile1()
i = -1
End If
If k = 210 Then
Timer1.Enabled = False
End If
i = i + 1
k = k + 1
End Sub
End Class