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

how to use mschart in my program

P: 1
hi can anyone help me, i'm having problem with mschart. i want to draw graph according to value in the Graph_Details table.i dont know where to start writing code and how. i have 0% knowledge on mschart and the coding. can someone help me.


My code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Timer2_Timer()
  2. Dim myvari As Integer
  3. Dim StartTime As Integer
  4. Dim StopTime As Integer
  5. Dim Store As Integer
  6. Dim timeGap As Integer
  7. Dim TimeEnd As String
  8. Dim avgSpeed As Long
  9. Dim NoOfCars As Integer
  10.  
  11.     Counter = Counter + 1
  12.     If Counter = 300 Then
  13.         Timer2.Enabled = False
  14.  
  15.         TimeEnd = Format(Now, "hh:mm:ss")
  16.  
  17.         strSql = "SELECT MAX(TimeGap) FROM Graph_Details"
  18.  
  19.         DataRs.Open strSql, DE.Conn, adOpenForwardOnly, adLockReadOnly
  20.  
  21.         If DataRs.RecordCount > 0 Then
  22.             If Not IsNull(DataRs(0)) Then
  23.                 timeGap = DataRs(0) + 1
  24.             Else
  25.                 timeGap = 1
  26.             End If
  27.         Else
  28.             timeGap = 1
  29.         End If
  30.  
  31.         DataRs.Close
  32.  
  33.         strSql = "SELECT TOP 150 TimeOut, Speed FROM Car_INFO ORDER BY ID DESC"
  34.  
  35.         'MsgBox strSql
  36.  
  37.         DataRs.Open strSql, DE.Conn, adOpenForwardOnly, adLockReadOnly
  38.  
  39.         If DataRs.RecordCount > 0 Then
  40.  
  41.         NoOfCars = 0
  42.         avgSpeed = 0
  43.  
  44.         For i = 0 To DataRs.RecordCount - 1
  45.             If Not DataRs(0) = "" Then
  46.                 NoOfCars = NoOfCars + 1
  47.                 avgSpeed = avgSpeed + DataRs(1)
  48.             End If
  49.             DataRs.MoveNext
  50.  
  51.         Next i
  52.  
  53.         avgSpeed = avgSpeed / NoOfCars
  54.  
  55.         End If
  56.  
  57.         DataRs.Close
  58.  
  59.         strSql = "INSERT INTO Graph_Details (TimeStart, TimeEnd, AverageSpeed, NoOfCars, TimeGap) " & _
  60.                     " VALUES ('" & lblTimeStart.Caption & "','" & TimeEnd & "','" & avgSpeed & "'," & _
  61.                     " '" & NoOfCars & "'," & timeGap & ")"
  62.  
  63.                     MsgBox strSql
  64.  
  65.                     DE.Conn.Execute strSql
  66.         Timer2.Enabled = True
  67.         Counter = 0
  68.         lblTimeStart.Caption = Format(Now, "hh:mm:ss")
  69.     End If
  70.  
  71. End Sub
May 6 '08 #1
Share this Question
Share on Google+
1 Reply


debasisdas
Expert 5K+
P: 8,127
please find a related discussion here for reference.
May 6 '08 #2

Post your reply

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