473,616 Members | 2,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

STORE average speed for every 5 min

27 New Member
hi this my code
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. car_count = 0
  3. Cumulative_Speed = 0
  4. End Sub
  5.  
  6.       Private Sub Timer1_Timer()
  7.  
  8.       Dim tmpNumber As Integer
  9.  
  10.       Dim i As Integer
  11.       Dim Counter As Integer
  12.       Timer1.Enabled = False    'stop timing while storing number
  13.       Counter = 0
  14.  
  15.       Randomize
  16.  
  17.       lbltmpNumber = Int(Rnd() * 15) + 1
  18.  
  19.       'check if this number already exist
  20.  
  21. For i = 0 To 9
  22.  
  23.         If lblCar(i) = lbltmpNumber And lblEnd(i) = "" Then
  24.  
  25.             'the number exist -> do not store it
  26.             EndTime = Now
  27.             lblEnd(i).Caption = Format(EndTime, "hh:mm:ss")
  28.             StartTime = lblTime(i)
  29.             Timeduration = (((DatePart("h", EndTime) - DatePart("h", StartTime)) * 3600) + ((DatePart("n", EndTime) - DatePart("n", StartTime)) * 60) + (DatePart("s", EndTime)) - DatePart("s", StartTime))
  30.             lblDuration(i).Caption = "" & Timeduration
  31.  
  32.             ' Count number of car which succesfully pass through reader 2
  33.  
  34.             car_count = car_count + 1
  35.             lblNum.Caption = car_count
  36.  
  37.             ' Call a function to calculate speed
  38.  
  39.             S = Speed()
  40.             lblSpeed(i).Caption = S
  41.             lblSpeed(i).Caption = Format(S, "###.00")
  42.  
  43.             ' Calculate the Average Speed
  44.  
  45.             Cumulative_Speed = Cumulative_Speed + S
  46.  
  47.             lblAverage.Caption = Format(Cumulative_Speed / car_count, "###.00")
  48.  
  49.             Timer1.Enabled = True
  50.  
  51. Exit For
  52.             ElseIf lblCar(i) = lbltmpNumber Then
  53.  
  54.             Timer1.Enabled = True
  55.  
  56. Exit For
  57.           End If
  58. Next
  59.  
  60.       'If this number does not exist -> store in Number Array
  61.  
  62.       If Timer1.Enabled = False Then
  63.       lblCar(Index).Caption = lbltmpNumber  'store the number
  64.       StartTime = Now
  65.       lblTime(Index).Caption = Format(StartTime, "hh:mm:ss")  'store the time
  66.       Index = Index + 1
  67.  
  68.  
  69.        End If
  70.  
  71.       If Index = 10 Then   'stop after stored 10 number
  72.  
  73.        Timer1.Enabled = False
  74.  
  75.  
  76.       Else  'do not reach 10
  77.       Timer1.Enabled = True    'continue storing
  78.  
  79.       End If
  80.  
  81.       End Sub
  82.  
  83.  
  84. Private Function Speed()
  85.  
  86. Speed = (100 / Timeduration) * (1000 / 3600)
  87. End Function
  88.  
My question here is how i modify my code to take total average speed for every 5 min.that means how to make car array reset and store the average then again display random number until 10 then store average n again an again until it 5 min. in 5 min all this array need to be sum and display the total average .
Mar 26 '08 #1
0 1235

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

Similar topics

12
2926
by: jose luis fernandez diaz | last post by:
Hi, My OS is: cronos:jdiaz:tmp>uname -a HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license I compile in 64-bits mode the program below:
3
5299
by: Tom Turner | last post by:
Here's the background on my situation. The question follows --- We have 600 units of mail going from our business to various Post Offices every morning. Every unit is accompanied by a paper Verification form which is signed and dated by a postal employee and returned to our office as proof of delivery. The Verification contains a 24 character barcode which holds a non-unique 5 digit postal zip code at pos 5-9, and a unique 10- digit...
11
3598
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a million lines. b) I need to store the contents into a unique hash. c) I need to then sort the data on a specific field. d) I need to pull out certain fields and report them to the user.
4
3401
by: Gary | last post by:
Hi, I have a temperature conversion program down pat, but I was told to add an average, meaning, i need to get the average temperature for as many times as it was entered. i do not know where to start, and my stpid book doesnt seem to help. here is my program #include <iostream.h> void main( ) {
1
2576
by: amit | last post by:
Hi guys I am using access database with Crystal Reports in VS2003 I am working on "Hospital Database" The fields are - Name - Date - ConsultingCharge - TotalFees i.e. Total Fees include fees for medicine issued by hospital In the report I want to display the Average of ConsultingCharge and TotalFees for every record.
1
3528
by: wetsprockets | last post by:
Hello, I have two tables, WindVector (wind data) and DOH_FC88to07 (water quality samples). The WindVector table has the following fields: Date (short date) Time (short time) WindSpeed WindDir WindDirRads V
9
4408
by: JuAn2226 | last post by:
HI I'M NEW IN VB6. i HAVE PROJECT WHICH REQUIRES ME TO STORE RANDOM NUM IN ARRAY N CAPTURE TIME FOR EACH OF THE NEW NUM IN THE ARRAY FORM. Actually my project is to calculate the average car speed. I have to code in vb for real-time application. for example i have to developed 10 array with name of the array is CarID.Each time a car passes the road the rfid reader will ditact the carID and store it in the array together the time the car reach...
2
3684
by: JuAn2226 | last post by:
hi,I got few question here. Hope some one can me. plz help me i running out of time 1. how to make my msflexgrid to display data for every 5 min(especially the number car and average speed. 2. Can the data from msflexgrid store in the database if yes how? Private Sub Form_Load() FillFlex
5
3170
by: p3rk3le | last post by:
So, I'm about to do a sequential search on a table (n contents) of random numbers. I have to print the average between the number of comparisons and the contents of the table (n) and the average time for each sequential search. I wrote:
0
8203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8146
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8592
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5550
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4063
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2579
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.