473,587 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.0001281830260 04728" for a
file size of 482KB.

Does any of this make sense? Any sugguestions?


Function CalculateDownlo adTime(intFileS ize 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 2481
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 CalculateDownlo adTime(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).ToStri ng("##':'").Pad Left(3, CType("0",
Char))
d = d Mod 3600
s = s + CType(d / 60, Integer).ToStri ng("##':'").Pad Left(3, CType("0",
Char))
d = d Mod 60
s = s + CType(d, Integer).ToStri ng("##")
Return s
End Function

bill

"D. Shane Fowlkes" <sh********** @h-o-t-m-a-i-l.com> wrote in message
news:Oj******** ******@TK2MSFTN GP11.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.0001281830260 04728" for a file size of 482KB.

Does any of this make sense? Any sugguestions?


Function CalculateDownlo adTime(intFileS ize 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_fdrs ucks.com> wrote in message
news:OA******** ******@TK2MSFTN GP10.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 CalculateDownlo adTime(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).ToStri ng("##':'").Pad Left(3, CType("0",
Char))
d = d Mod 3600
s = s + CType(d / 60, Integer).ToStri ng("##':'").Pad Left(3, CType("0",
Char))
d = d Mod 60
s = s + CType(d, Integer).ToStri ng("##")
Return s
End Function

bill

"D. Shane Fowlkes" <sh********** @h-o-t-m-a-i-l.com> wrote in message
news:Oj******** ******@TK2MSFTN GP11.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.0001281830260 04728"
for

a
file size of 482KB.

Does any of this make sense? Any sugguestions?


Function CalculateDownlo adTime(intFileS ize 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
5819
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
3097
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
6934
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 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.
4
38958
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 done? Thanks, Rich
1
2751
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"); //return 01:00:00 I want "00:00:00" instead of "12:00:00", what is going wrong?
5
10549
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 the ability to do some basic arithmetic in these formats. I think that there just has to be a package or module out there that already does this with reasonable speed and accuracy.
1
1918
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
3162
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 format. I have tried timedelta as well as time.ctime. Does anyone have any suggestions? Thanks.
1
2675
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 want to generate a an excell sheet of that table but here i want the time to be like mm:ss but not hh:mm:ss examle the length of song sweet dreams is 01:12:35 now i want this to be shown as 72:35 how is there any procedure to convert directly in...
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.