473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Calculating elapsed time

Morning...

Am working on a simple billing system and a looking for a code that can help calculate the difference in time between sessions..(am using VB.Net )

This is what is happening:

l have a :
combobox named combobox1
textbox named txttotalamount
btnStart
Timer 1
btnEnd

Under btnStart l have the following code:
Expand|Select|Wrap|Line Numbers
  1. Me.Timer1.Start()
  2.             Me.Timer1.Start()
  3.             Me.Timer1.Enabled = True
  4.  
and under btnEnd l have the following code:
Expand|Select|Wrap|Line Numbers
  1.         Me.Timer1.Stop()
  2.         Me.txtTotaltime.Text = m_seconds.ToString()
  3.         Dim number1 As Integer
  4.         Dim number2 As Integer
  5.         Dim answer As Integer
  6.         number1 = txtTotaltime.Text
  7.         number2 = ComboBox1.Items.Count
  8.         answer = number1 * number2
  9.         MsgBox(answer)
What l want is that l should be able to use the system time..if the system time is 12:01 that should be my start time and my end time should also be taken from the system..the counting should be in minutes..please help me
Oct 28 '08 #1
4 2153
jg007
283 100+
depending on what you are trying to do you might find it easier to use the ' stopwatch ' class
Oct 28 '08 #2
jg007
283 100+
you can also do subtract one date value from another to return a timespan value and then extract the minutes

Expand|Select|Wrap|Line Numbers
  1.  
  2.  elapsed = TimeEnd - TimeStart
  3.  
  4.  totalmin = elapsed.TotalMinutes
  5.  
  6.  
Oct 28 '08 #3
I have a web app that post response time between a start and stop time I am using timespan and when the interval goes to the next date it shows an incorrect negative value. Also I am only displaying whole numbers rounded to nearest minute.

Can anyone help with times that surpass midnight and go into next day? Any help Appreciated.
''StartDatetime and StopDateTime difference is written to me.alarmlocid.text (#) removes the .000etc

Expand|Select|Wrap|Line Numbers
  1. Dim dteStartDateTime As Date = CDate(Me.StartDateTime().Text)
  2. Dim dteStopDateTime As Date = CDate(Me.StopDateTime().Text)
  3. Dim tsTimeSpan As Timespan
  4. Dim iTotalTime As Double
  5.  
  6. tsTimeSpan = dteStopDateTime.Subtract(dteStartDateTime)
  7.  
  8. iTotalTime = tsTimeSpan.TotalMinutes
  9.  
  10. Me.AlarmLocId.Text = iTotalTime.ToString("#")
Apr 6 '09 #4
Plater
7,872 Expert 4TB
I have never had an issue with TimeSpans not being able to handle going on to the next day.
I would think it has something to do with using the wrong objects. You should be using DateTime objects, not Date objects.
What values are in Me.StartDateTime().Text and Me.StopDateTime().Text exactly?
Does CDate provide the same functionality as the .NET equiv of DateTime.Parse() ?
Apr 6 '09 #5

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

Similar topics

5
by: Ron Adam | last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone here for a great programming language. Below is my first Python program (not my first program) and I'd apreciate any...
12
by: Ola Natvig | last post by:
Hi all Does anyone know of a fast way to calculate checksums for a large file. I need a way to generate ETag keys for a webserver, the ETag of large files are not realy nececary, but it would be...
3
by: T-Narg | last post by:
I would like to produce the following output based on my XML file: My Album (2005) Elapsed Time (hh:mm:ss): 00:07:00 Song 1: title1 Length (hh:mm:ss): 00:02:30 Song 2: title2 Length...
4
by: bonehead | last post by:
Greetings, A friend tells me that he has not been able to work out an expression that calculates elapsed minutes from TimeA to TimeB. For example: TIMEA TIMEB ELAPASED...
1
by: pauly | last post by:
Hello All, I have been trying to create a query that extracts data from a table and calculates the elapsed time between records. The table called "Imported_table". I need to be able to calculate...
20
by: Jean Johnson | last post by:
Hello - I have a start and end time that is written using the following: time.strftime("%b %d %Y %H:%M:%S") How do I calculate the elapsed time? JJ
1
by: oakwoodman | last post by:
I writing a Linux db2 udb sql script, not procedure, and one of the things that I would like to add is the elapsed time that the script runs. I'm having trouble defining start_time, end_time and...
4
by: Brian | last post by:
I have a 2000/2002 Access db that I use to collect and store my exercisetime using a form to enter. I wanted to see a summary of the total timefor each exercise so I have a subform that does this....
1
by: bklernr | last post by:
Hello, I'm working on a form in Acrobat Pro 9 (not LiveCycle). I need to have an operator enter a beginning time (firsttime) & an end time (secondtime) & when s/he pushes a button (btncalcmix.0),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.