We help IT Professionals succeed at work.
Get Started

VB.NET, Timer creation on the fly with different timer values

490 Views
Last Modified: 2013-11-26
I am calling a new class to start a logging session of different devices.

I need to create a timer control along with the sub-code that will be run for EACH timer being created in a loop



    Private Sub create_log_timers()

        Me.SensorMonitorTableAdapter.Fill(Me.Sensormonitor_Dataset.Sensors, True, serial_num)

        Dim x As Integer = 0
        Do Until x = Me.SensorMonitor_DataGridView.RowCount
            int_port = Me.SensorMonitor_DataGridView.Item(1, x).Value                                  ' get port #  - working
            sen_log_time = Me.SensorMonitor_DataGridView.Item(6, x).Value                          ' get port log time ---- working
            Dim y = "textbox" + int_port ' place on value on sensor change event to a text box linked to interface port # - working
            Dim t As New Timer ' Create a timer with port num as name


            ' ----- create timer code to send event to log
'write - private_sub timer(int_port) (by val...) handles timer(int_port).tick
 write  -         senslog.write_s_Log(Date.Now, int_port, sensorInArray(int_port).Text)
write  - end sub
            '-------
            t.Interval = sen_log_time
            t.Enabled = True
            t.Start()

        Loop

    End Sub



Thanks!
Comment
Watch Question
This problem has been solved!
Unlock 2 Answers and 2 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE