Home All Groups Group Topic Archive Search About
Author
13 Dec 2006 2:33 AM
cj
Dim starttime As DateTime
Dim finishtime As DateTime
Dim elapsed As TimeSpan

starttime=now()
some processing
finishtime=now()
elapsedtime=finishtime.subtract(starttime)
messagebox.show(???????????????)

what would I show in the message box if I wanted a message like 1:37 to
indicate it took 1 hr and 37 minutes to run some processing.

I've displayed minutes before but this event could be between a minute
and a few hours.

I guess I could do elapsed.hours & ":" & elapsed.minutes

Is that the best way?

Author
13 Dec 2006 3:03 AM
Mark Ingalls
Hello cj,

Give elapsedtime.ToString() a shot and see if that's what you want.

Thanks,
Mark

Show quoteHide quote
> Dim starttime As DateTime
> Dim finishtime As DateTime
> Dim elapsed As TimeSpan
> starttime=now()
> some processing
> finishtime=now()
> elapsedtime=finishtime.subtract(starttime)
> messagebox.show(???????????????)
> what would I show in the message box if I wanted a message like 1:37
> to indicate it took 1 hr and 37 minutes to run some processing.
>
> I've displayed minutes before but this event could be between a minute
> and a few hours.
>
> I guess I could do elapsed.hours & ":" & elapsed.minutes
>
> Is that the best way?
>
Author
13 Dec 2006 5:46 AM
Walter Wang [MSFT]
TimeSpan.ToString() always use a fixed format to output the string, such as
00:00:02.0001664.

To get the customized format, you could just either use string concat or
use string.Format:

Message.Show(string.Format("{0}:{1}", elapsed.Hours, elapsed.Minutes))



Sincerely,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
13 Dec 2006 1:19 PM
cj
Thanks!

Walter Wang [MSFT] wrote:
Show quoteHide quote
> TimeSpan.ToString() always use a fixed format to output the string, such as
> 00:00:02.0001664.
>
> To get the customized format, you could just either use string concat or
> use string.Format:
>
> Message.Show(string.Format("{0}:{1}", elapsed.Hours, elapsed.Minutes))
>
>
>
> Sincerely,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications. If you are using Outlook Express, please make sure you clear the
> check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
> promptly.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
Author
14 Dec 2006 1:52 AM
Jay B. Harlow
cj,
In addition to the other comments.

I will convert the TimeSpan to a DateTime if I need custom Formatting:


    Dim seconds As Integer = 75
    Dim elapsed As TimeSpan = TimeSpan.FromSeconds(seconds)

> elapsed  = finishtime.subtract(starttime)

    Dim value As DateTime = DateTime.MinValue.Add(elapsed)
    Dim s As String = value.ToString("mm:ss")

> messagebox.show(???????????????)


--
Hope this helps
Jay B. Harlow
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


Show quoteHide quote
"cj" <cj@nospam.nospam> wrote in message
news:uKZBT8lHHHA.4804@TK2MSFTNGP03.phx.gbl...
> Dim starttime As DateTime
> Dim finishtime As DateTime
> Dim elapsed As TimeSpan
>
> starttime=now()
> some processing
> finishtime=now()
> elapsedtime=finishtime.subtract(starttime)
> messagebox.show(???????????????)
>
> what would I show in the message box if I wanted a message like 1:37 to
> indicate it took 1 hr and 37 minutes to run some processing.
>
> I've displayed minutes before but this event could be between a minute and
> a few hours.
>
> I guess I could do elapsed.hours & ":" & elapsed.minutes
>
> Is that the best way?