472,961 Members | 2,130 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

Help with Function - converting a double num into a hh:mm:ss format

Here's a good one. I've been using an Excel spreadsheet for the past couple
of years to calculate a file's Estimated Download Time based off of a solid
50kbs connection (dial up). This is for a downloads page such as:

http://www.drpt.virginia.gov/downloa...cat.aspx?ID=12

The formula is basically this:
=(((C4*1000*8)/50000)/84600)*1.1

(Estimate is calculated on a modem dial up connection of 50Kbs and transfer
loss of 10% due to the modulation and demodulation that modems must perform
with a dial up connection.)

"C4" would be where I plug in the KB size such as "482" and it gives me a
estimated download time of 1:27 (mm:ss). The cell that returns this is
formatted as time.

Now, I'm trying to write a VB.NET (ASP) function that calculates this for me
when the record is automatically inserted in the table. The field that holds
this "EDT" is simply a text field and I've alway manually calculated this
with the Excel file and typed it in.
I've tried the Function below but not having a lot of luck. Not getting
errors...just no conversion seems to work. If I KEEP the
ToString("hh:mm:ss:), I literally get "hh:mm:ss: inserted into the database.
If I remove it and simply Return dblEDT, I get " 0.000128183026004728" for a
file size of 482KB.

Does any of this make sense? Any sugguestions?


Function CalculateDownloadTime(intFileSize As Integer) As String

' Estimate is calculated on a modem dial up connection of 50Kbs and transfer
loss
' of 10% due to the modulation and demodulation that modems must perform
with
' a dial up connection.

Dim dblEDT As Double

dblEDT = (((intFileSize)/50000)/84600)*1.1

Return dblEDT.ToString("hh:mm:ss")

End Function
Nov 19 '05 #1
2 2430
Not sure exactly where you are getting the 84600 from, but you can't use the
Double.ToString() to perform the type of formatting you want to accomplish.
You should just do it by hand.

Function CalculateDownloadTime(ByVal size As Integer) As String

Dim d As Double

d = (size * 8 / 50000) * 1.1

Dim s As String
s = CType(d / 3600, Integer).ToString("##':'").PadLeft(3, CType("0",
Char))
d = d Mod 3600
s = s + CType(d / 60, Integer).ToString("##':'").PadLeft(3, CType("0",
Char))
d = d Mod 60
s = s + CType(d, Integer).ToString("##")
Return s
End Function

bill

"D. Shane Fowlkes" <sh**********@h-o-t-m-a-i-l.com> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Here's a good one. I've been using an Excel spreadsheet for the past couple of years to calculate a file's Estimated Download Time based off of a solid 50kbs connection (dial up). This is for a downloads page such as:

http://www.drpt.virginia.gov/downloa...cat.aspx?ID=12

The formula is basically this:
=(((C4*1000*8)/50000)/84600)*1.1

(Estimate is calculated on a modem dial up connection of 50Kbs and transfer loss of 10% due to the modulation and demodulation that modems must perform with a dial up connection.)

"C4" would be where I plug in the KB size such as "482" and it gives me a
estimated download time of 1:27 (mm:ss). The cell that returns this is
formatted as time.

Now, I'm trying to write a VB.NET (ASP) function that calculates this for me when the record is automatically inserted in the table. The field that holds this "EDT" is simply a text field and I've alway manually calculated this
with the Excel file and typed it in.
I've tried the Function below but not having a lot of luck. Not getting
errors...just no conversion seems to work. If I KEEP the
ToString("hh:mm:ss:), I literally get "hh:mm:ss: inserted into the database. If I remove it and simply Return dblEDT, I get " 0.000128183026004728" for a file size of 482KB.

Does any of this make sense? Any sugguestions?


Function CalculateDownloadTime(intFileSize As Integer) As String

' Estimate is calculated on a modem dial up connection of 50Kbs and transfer loss
' of 10% due to the modulation and demodulation that modems must perform
with
' a dial up connection.

Dim dblEDT As Double

dblEDT = (((intFileSize)/50000)/84600)*1.1

Return dblEDT.ToString("hh:mm:ss")

End Function

Nov 19 '05 #2
Thanks...I'll try your solution and see what happens. The 84600 is second
in a day. I needed this to figure out how seconds it took to download X bits
of data.


"William F. Robertson, Jr." <theman_at_fdrsucks.com> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl...
Not sure exactly where you are getting the 84600 from, but you can't use
the
Double.ToString() to perform the type of formatting you want to
accomplish.
You should just do it by hand.

Function CalculateDownloadTime(ByVal size As Integer) As String

Dim d As Double

d = (size * 8 / 50000) * 1.1

Dim s As String
s = CType(d / 3600, Integer).ToString("##':'").PadLeft(3, CType("0",
Char))
d = d Mod 3600
s = s + CType(d / 60, Integer).ToString("##':'").PadLeft(3, CType("0",
Char))
d = d Mod 60
s = s + CType(d, Integer).ToString("##")
Return s
End Function

bill

"D. Shane Fowlkes" <sh**********@h-o-t-m-a-i-l.com> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Here's a good one. I've been using an Excel spreadsheet for the past

couple
of years to calculate a file's Estimated Download Time based off of a

solid
50kbs connection (dial up). This is for a downloads page such as:

http://www.drpt.virginia.gov/downloa...cat.aspx?ID=12

The formula is basically this:
=(((C4*1000*8)/50000)/84600)*1.1

(Estimate is calculated on a modem dial up connection of 50Kbs and

transfer
loss of 10% due to the modulation and demodulation that modems must

perform
with a dial up connection.)

"C4" would be where I plug in the KB size such as "482" and it gives me a
estimated download time of 1:27 (mm:ss). The cell that returns this is
formatted as time.

Now, I'm trying to write a VB.NET (ASP) function that calculates this for

me
when the record is automatically inserted in the table. The field that

holds
this "EDT" is simply a text field and I've alway manually calculated this
with the Excel file and typed it in.
I've tried the Function below but not having a lot of luck. Not getting
errors...just no conversion seems to work. If I KEEP the
ToString("hh:mm:ss:), I literally get "hh:mm:ss: inserted into the

database.
If I remove it and simply Return dblEDT, I get " 0.000128183026004728"
for

a
file size of 482KB.

Does any of this make sense? Any sugguestions?


Function CalculateDownloadTime(intFileSize As Integer) As String

' Estimate is calculated on a modem dial up connection of 50Kbs and

transfer
loss
' of 10% due to the modulation and demodulation that modems must perform
with
' a dial up connection.

Dim dblEDT As Double

dblEDT = (((intFileSize)/50000)/84600)*1.1

Return dblEDT.ToString("hh:mm:ss")

End Function


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: KathyB | last post by:
Hi, not too swift with anything other than simple SQL statements, so I'm looking for some help. Using SQL Server 2000 with this stored proc: (@varCust varchar(50)) AS SET NOCOUNT ON
6
by: Able | last post by:
Dear friends I need to format seconds as hh:mm:ss. I see a lot of coding transforming seconds to hh:mm:ss. Somebody know a short way? Regards Able
2
by: Robert Brown | last post by:
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...
4
by: Rich | last post by:
Now.ToShortTimeString returns 9:13 PM. I would like to get this in miliatry time with seconds included 21:13:45 (or something like that - just military time with seconds). How can this be...
1
by: Jason Chan | last post by:
DateTime mydate = new DateTime(2006,1,1,0,0,0); string testStr = mydate.ToString("hh:mm:ss"); //return 12:00:00 mydate = new DateTime(2006,1,1,1,0,0) testStr = mydate.ToString("hh:mm:ss");...
5
by: kpp9c | last post by:
Hi, I was looking at python & datetime and hoping that it would already have a method/func to translate time formats. I need to translate seconds to hh:mm:ss.ms and vice versa and would like...
1
by: Vishal Bhargava | last post by:
Is there an inbuilt library in Python which you can use to convert time in seconds to hh:mm:ss format? Thanks, Vishal
1
by: unknown66 | last post by:
hello, I have a time value in unix time that I would like to convert into a time format of hh:mm:ss:ms. For example, I have this number, 1172234138451, that I would like to be in the hh:mm:ss:ms...
1
seshu
by: seshu | last post by:
Hi every body to morning my cousine has show his application and also his live db in that to sav the length of all the voice files he has saved in time format ie he took the datatype of time now i...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.