|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Calculating Time in VB .NetI'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" <Br***@discussions.microsoft.com> schrieb Have a look at the very helpful DateTime (called Date in VB.Net but they are > 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! > identic) and TimeSpan types and there members. Armin "Cor Ligthert" wrote: No, not a student. Thanks for asking though. Just a database analyst who > 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 likes to run and trying to add some programming by starting off with something really basic. Have to start small you know. Show quoteHide quote "Armin Zingler" wrote: Thanks Armin! Will do.> "Brian" <Br***@discussions.microsoft.com> schrieb > > 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 > > 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 I thought that I gave the link
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtimespanclassfromsecondstopic.asp Cor |
|||||||||||||||||||||||