hi,
i want to log the data continuously to the text file.
On a first click of button the data logging should start and log the data to txt file
on a second click it should stop the data logging.
how to achieve this
Thanks in advance
What I have tried:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Application.DoEvents()
bt_count3 = bt_count3 + 1
If bt_count3 <= 1 Then
v4klog.FileName = DateTime.Now.ToString("ddMMyyyy") & "_" & DateTime.Now.ToString("HHmmss") & "v4k.xls"
If v4klog.ShowDialog() = Windows.Forms.DialogResult.OK Then
v4klogfile_name = v4klog.FileName
nc1 = 0
nr1 = 2
V4kworkbook = xlapp2.Workbooks.Add(1)
V4kworksheet = V4kworkbook.Sheets("sheet1")
V4kworksheet.Cells(1, 1) = "TR1"
V4kworksheet.Cells(1, 2) = "TR2"
file2_count = 0
Button3.Text = "STOP"
Button3.ForeColor = Color.Red
enable_v4k = True
End If
End If
If bt_count3 >= 2 Then
Button3.Enabled = False
Button3.Text = "START"
Button3.ForeColor = Color.Green
bt_count3 = 0
If enable_v4k = True Then
enable_v4k = False
v4ksave.Visible = True
lbv4ksave_status.Visible = True
For k = 3 To 4002
Application.DoEvents()
V4kworksheet.Cells(1, k) = "C" & k - 2
v4ksave.Value = k
Next
v4ksave.Visible = False
For j = 1 To 10
lbv4ksave.Visible = True
delay1(100)
lbv4ksave.Visible = False
delay1(100)
Next
lbv4ksave_status.Visible = False
Button3.Enabled = True
V4kworksheet.Range("A1:EWX1").HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlCenter
V4kworkbook.SaveAs(v4klogfile_name)
V4kworkbook.Close()
xlapp2.Quit()
End If
End If
End Sub