Calculating Time in VB .Net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm learning to program with VB .Net. I'm trying to write a program that
will calculate jogging time. I have Text boxes for Distance1, Distance2,
Speed1, Speed2, Time1, Time2, and Total Time. For example, say I run 2 miles
at 8mph (7:30 minute miles) and 1 mile at 7.5mph (8 minute miles). I enter 2
in Distance1, 1 in Distance2, 8 in Speed1, and 7.5 in Speed2. I can
calculate in decimal (10.25, 10.5, 10.75 minutes, etc.) How would I
calculate the three times in minutes and seconds (10:15. 10:30, 10:45)?
Thanks!
 
Brian,

This sounds like a student question.

Basicly you calculate it in the same way as on a piece of paper, however you
use than some code to do that, which differs not much from that.

Cor
 
Brian said:
I'm learning to program with VB .Net. I'm trying to write a program
that will calculate jogging time. I have Text boxes for Distance1,
Distance2, Speed1, Speed2, Time1, Time2, and Total Time. For
example, say I run 2 miles at 8mph (7:30 minute miles) and 1 mile at
7.5mph (8 minute miles). I enter 2 in Distance1, 1 in Distance2, 8
in Speed1, and 7.5 in Speed2. I can calculate in decimal (10.25,
10.5, 10.75 minutes, etc.) How would I calculate the three times in
minutes and seconds (10:15. 10:30, 10:45)? Thanks!


Have a look at the very helpful DateTime (called Date in VB.Net but they are
identic) and TimeSpan types and there members.

Armin
 
Cor Ligthert said:
Brian,

This sounds like a student question.

Basicly you calculate it in the same way as on a piece of paper, however you
use than some code to do that, which differs not much from that.

Cor

No, not a student. Thanks for asking though. Just a database analyst who
likes to run and trying to add some programming by starting off with
something really basic. Have to start small you know.

Armin Zingler said:
Have a look at the very helpful DateTime (called Date in VB.Net but they are
identic) and TimeSpan types and there members.

Armin

Thanks Armin! Will do.
 
Brian,

Than in addition to Armin is TimeSpan what you need and than the method
"FromSeconds" or an equivalent. I write that because I have seen that these
ones are easily missed.

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top