473,324 Members | 1,856 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,324 software developers and data experts.

Calculating speed using distance/time problem

1
hi
I recently coded a program which displays the timespan between 2 different times. I used the DateTime function to do this but now i can't calculate the speed as you cannot use DateTime in division, is there another function i should use?
This is my code so far:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Class Form1
  3.     Dim starttime As DateTime
  4.     Dim endtime As DateTime
  5.     Dim timetaken As TimeSpan
  6.     Dim registration As String
  7.     Dim Distance As Integer
  8.     Dim speed As Decimal
  9.  
  10.  
  11.     Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
  12.         starttime = DateTime.Parse(txtStart.Text)
  13.         endtime = DateTime.Parse(txtEnd.Text)
  14.         timetaken = endtime - starttime
  15.         registration = txtReg.Text
  16.         Distance = 500
  17.  
  18.         speed = Distance / timetaken
  19.  
  20.     End Sub
  21. End Class
  22.  
Feb 11 '15 #1
2 4246
Luuk
1,047 Expert 1GB
You could use DateTime.Ticks

But you should verify that starttime and endtime are on the same date.
Feb 14 '15 #2
Killer42
8,435 Expert 8TB
I believe you're in the wrong forum. That looks like VB.Net code, and this is the VB6 (very old pre-dotnet version) forum. That's probably why you haven't seen much of a response.

Speaking strictly from a VB6 perspective, I would have suggested using the DateDiff() function to get the difference as a number of known units - most likely seconds. But I have no idea what the VB.Net equivalent would be. Perhaps a search for something like "datediff VB.Net equivalent" would be fruitful.
Apr 4 '15 #3

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

Similar topics

3
by: idikoko | last post by:
I have a small problem I am trying to extract charcters from one string store it in another and then compare the new string and out a msg. The code looks fine but it always runs into a compiler...
4
by: Jean-François Michaud | last post by:
Hello, I've been looking at this for a bit now and I don't see what's wrong with the code. Can anybody see a problem with this? Here is an XSLT snippet I use. <xsl:template match="graphic">...
6
by: remya1000 | last post by:
i'm using Vb.net. i need to find out the remote machine's time by using NET TIME. NET TIME i got this help from internet while searching. but while using this code i'm not able to display...
2
by: dablyz | last post by:
Hi! I was wondering if I could get some more excellent advice from this site. I'm designing a project that ultimately, among other functions, calculates a download time based upon a file size...
7
by: Shani Aulakh | last post by:
Hi there, I have a FolderWatcher.cs class that will monitor a given folder and delete files older than X number of days. I have the following methods. I need to add/show delete mothod using date...
0
by: =?Utf-8?B?Ym9i?= | last post by:
Hi, I am using asp.net 2.0 secuirty model and its using UTC time. I want to change it to PST (time zone). Is there any configuration to change to PST timezone? Thanks
5
by: KusoYumi | last post by:
Hello, im facing date and time problem. I want get a time in Date Type, with this format HH:mm:SS i try to get new Date(), then format it as String. Then i use substring to get the time. Then i...
2
by: =?Utf-8?B?Z3JlYXRiYXJyaWVyODY=?= | last post by:
Hi, I know there isn't a specific event property for the download speed, but can anyone tell me how to find it? I'm not sure how to write the code. Thanks, Jason
0
by: Gabriel Genellina | last post by:
En Tue, 14 Oct 2008 18:08:53 -0300, Joe Python <jopython@gmail.com> escribió: The pattern must match the *separator* only. Try with: pattern = r'\d+/\d+/\d+ \d+:\d+:\d+ (AM|PM)' -- Gabriel...
4
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.