By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

upadate label TimeEnd and labelTime Start

P: 27
Hi, can someone help me with the coding. I want to update the label TimeStart and label TmeEnd every 5 min. Can someone show how to do it. In this pogrom the label TimeStart only display first time when the form load but the label TimeStart not update with new time when msgbox revoke same goes to label EndTime. plz help me.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer2_Timer()
  2. On Error Resume Next
  3.  
  4. Dim myvari As Integer
  5. Dim StartTime As Integer
  6. Dim StopTime As Integer
  7.  
  8. Dim Store As Integer
  9. Dim timeGap As Integer
  10. Dim avgSpeed As Long
  11. Dim NoOfCars As Integer
  12.  
  13.  
  14. If Timer2.Enabled = True Then
  15.  
  16.     GraphTimeIncrement = GraphTimeIncrement + 1
  17.  
  18.    If GraphTimeIncrement >= 1 Then
  19.  
  20.         GraphStopTime = DatePart("n", Now())
  21.         myvari = MsgBox("start time " & GraphStartTime & " Stop Time " & GraphStopTime, vbOKOnly)
  22.         frmDisplay.Show
  23.         lblTimeEnd.Caption = Format(Now, "hh:mm:ss")
  24.         frmDisplay.txtTimeEnd.Text = Format(Now, "hh:mm:ss")
  25.         If myvari = vbOK Then
  26.             frmMain.Refresh
  27.             Timer1.Enabled = True
  28.         End If
  29.  
  30.  
  31. DataRs.Open strSql, DE.Conn, adOpenForwardOnly, adLockReadOnly
  32.  
  33.         If DataRs.RecordCount > 0 Then
  34.             'NoOfCars = DataRs(0)
  35.             'avgSpeed = DataRs(1)
  36.         End If
  37.  
  38.         DataRs.Close
  39.  
  40.         strSql = "INSERT INTO RESULTS (TimeStart, TimeEnd, AverageSpeed, NoOfCars, TimeGap) " & _
  41.                     " VALUES ('" & lblTimeStart.Caption & "','" & lblTimeEnd.Caption & "','" & lblAverage & "'," & _
  42.                     " '" & lblNum.Caption & "'," & timeGap & ")"
  43.  
  44.                     DE.Conn.Execute strSql
  45.  
  46.         GraphTimeIncrement = 0
  47.         GraphStartTime = DatePart("n", Now())
  48.         GraphStopTime = 0
  49.     Else
  50.         Timer2.Enabled = True
  51.     End If
  52.  End If
  53. End Sub
Apr 30 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.