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

How to calculate the difference in time

100+
P: 102
I have an app that captures the start time and end time of a process.

Start time:
Expand|Select|Wrap|Line Numbers
  1. lbl_Start.text = Now()         ' display start time
  2. Dim STARTx As DateTime = Now() ' capture start time
  3. '
  4. 'Code follows
  5. '
  6.  
End Time
Expand|Select|Wrap|Line Numbers
  1. '
  2. 'Code ends
  3. '
  4. lbl_STOPx.text = Now()        ' Display End Time
  5. Dim STOPx As DateTime = Now()  'Capture End Time
  6. Dim spanx As TimeSpan = STOPx.Subtract(STARTx) 'compute total time
  7. lbl_POTotalTime.Text = spanx.ToString ' display total time 
  8.  
All I get is nothing for the displaying end time and nothing foe the computation of end time. What's wrong?
Jan 25 '18 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,035
Try to change line #7 to:
Expand|Select|Wrap|Line Numbers
  1. lbl_POTotalTime.Text = spanx.Milliseconds.ToString ' display total time 
If than helps, than this should be cause by your default date-format?
Jan 27 '18 #2

Post your reply

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