Convert a double to a format of hh:mm:ss

  • Thread starter Thread starter Robert Brown
  • Start date Start date
R

Robert Brown

Hi all.

I have written a program that transfers data via FTP. I can calculate
the rough amount of time left. I get a value such as 70.83 seconds
left for instance.

What I want to do is to change this to hh:mm:ss format. Obviously,
VB.NET doesn't seem to want to convert this unless it is already a
DATETIME cast.

Has anyone done this before, or could give me some pointers to
accomplish the conversion.

Thanks,
Robert
 
Hi all.

I have written a program that transfers data via FTP. I can calculate
the rough amount of time left. I get a value such as 70.83 seconds
left for instance.

What I want to do is to change this to hh:mm:ss format. Obviously,
VB.NET doesn't seem to want to convert this unless it is already a
DATETIME cast.

Has anyone done this before, or could give me some pointers to
accomplish the conversion.

Look at the TimeSpan structure. You can use the "FromSeconds" method to
create the structure and then the ToString() method (with a proper
format string) to get the results you'd like.
 
Fantastic... just what I needed.

I thought there would have been somthing to do it (rather than a
manual coding of it).

It worked exactly how I wanted it,and the structure will help me
replace some code in another project.

Thanks again,
Robert
 
Back
Top