title: How to count the value of timer in VB
body: <p>I am using timer in my code. I am setting 1s timer for serial data receive from arduino. Now, I wanted to write into excel file for every 1 min. using timer. Indivually it working fine. Writing into excel for every 1s. But i wanted to write for every 1min.
  Below i posted timer code. which is being set for 1s. when 1 s gets over increment counter  and display count value on text box.</p>
  
  <p>If count value reach 60 means 1 min. then write to excel sheet else keep incrementing .</p>
  
  <p>Here is my part of code</p>
  
  <pre><code> Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
          Dim counter As Integer
          Try
  
              SerialPort1.Write("c")
              System.Threading.Thread.Sleep(250)
              Dim k As Double
              Dim value As String = SerialPort1.ReadLine()
              k = CDbl(distance)
              ListBoxSensor.Text = k
  
              Dim s As New Series
              s.Points.AddXY(1000, k)
              Chart1.Series.Add(s)
              Count_val.Text = counter
  
              If counter = 6 Then
                  Dim headerText = ""
                  Dim csvFile As String = IO.Path.Combine(My.Application.Info.DirectoryPath, "Current.csv")
  
                  If Not IO.File.Exists((csvFile)) Then
                      headerText = "Date&amp; time ,value, "
  
                  End If
  
                  Using outFile = My.Computer.FileSystem.OpenTextFileWriter(csvFile, True)
                      If headerText.Length &gt; 0 Then
                          outFile.WriteLine(headerText)
                      End If
                      Dim y As String = DateAndTime.Now()
                      Dim x As String = y + "," + value
                      outFile.Write(x)
  
                  End Using
              End If
  
          Catch ex As Exception
  
          End Try
  
      End Sub
  </code></pre>