I would like to run a specific function when the timer reach 50 a message box will show and then the specific functions run, and resets it back to 0, could you help review and add codes that may help me with it?
Note: label1.text is where the timer shows
Appreciate your help.
Thank you in advance
Here's the code I've been working on:
If label1.text = "50" Then
MessageBox.Show("Please wait were updating the data table..")
Timer1.Stop()
Dim sqlquery As String = "SELECT PT_N_Std_Tuning, PT_TimeIn, PT_TimeOut, Variant FROM tbl_V9_Datalog WHERE Variant = '5' AND dateadd(hour, -1, dateadd(hour,datediff(hour,0,getdate()),0)) <= [PT_TimeIn]
and PT_TimeIn < dateadd(hour,datediff(hour,0,getdate()),0) ORDER BY PT_TimeIn ASC"
Dim reader As SqlDataReader
Dim adapter As New SqlDataAdapter
Dim command As New SqlCommand
command.CommandText = sqlquery
command.Connection = conn1
adapter.SelectCommand = command
'command.Parameters.Add("@variantno", SqlDbType.VarChar).Value = cmbox_variant.Text
reader = command.ExecuteReader
Dim DataTableName As String = textbox1.text
Dim dValue As Double
Dim ID1 As String = ""
Dim ID2 As String = ""
Dim ID3 As String = ""
Dim ID4 As String = ""
Dim ID5 As String = ""
Dim ID6 As String = ""
Dim ID7 As String = ""
Dim ID8 As String = ""
Dim ID9 As String = ""
Dim ID10 As String = ""
Dim ID11 As String = ""
Dim ID12 As String = ""
Dim Note1 As String = ""
Dim Note2 As String = ""
Dim sDate As String = ""
Dim sTime As String = ""
Dim wd As Int32 = S2K_SetDataTableVariableValue(DataTableName, dValue, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, ID9, ID10, ID11, ID12, Note1, Note2, sDate, sTime)
Try
If reader.HasRows Then
While reader.Read()
dValue = (Val(reader.Item("PT_N_Std_Tuning").ToString))
DataTableName = TextBox1.Text
ID1 = reader.Item("PT_TimeIn").ToString
ID2 = ""
ID3 = ""
ID4 = ""
ID5 = ""
ID6 = ""
ID7 = ""
ID8 = ""
ID9 = ""
ID10 = ""
ID11 = ""
ID12 = ""
Note1 = "" 'reader.Item("AttemptNo").ToString
Note2 = ""
Dim sDate1 = reader.GetOrdinal("PT_TimeOut")
sDate = reader.GetDateTime(sDate1).ToShortDateString
Dim sTime1 = reader.GetOrdinal("PT_TimeOut")
sTime = reader.GetDateTime(sTime1).ToLongTimeString
wd = S2K_SetDataTableVariableValue(DataTableName, dValue, ID1, ID2, ID3, ID4, ID5, ID6, ID7, ID8, ID9, ID10, ID11, ID12, Note1, Note2, sDate, sTime)
End While
MessageBox.Show("Data has been updated")
End If
End If
What I have tried:
Please refer on the codes, I have used the label1.text but it does not run the function after reaching the 50.