
Formating Text From Database
Hi<BR>I have 2 problems. I get the text from database in format like:<BR>259 and need to transform it to 2:59 min...<BR>&<BR>4144089 and need to transform it to 4.1MB<BR>Please Help me<BR>Thanks<BR>

RE: Formating Text From Database
Response.write FormatNumber((4144089/1000000),1,1) & "MB"<BR>Response.write "<BR>"<BR>Response.write Left(259,Len(259)Len(Right(259,2))) & ":" & Right(259,2)

RE: Formating Text From Database

RE: Formating Text From Database
will the number you are converting to MB be the same length everytime and will the time only be three digits everytime (2:59)<BR>what about 12:59 ??

LOOK AT THIS :)
x = 4144089<BR>y = (len(x)  1)<BR>z = 0<BR>a = y<BR>c = y<BR>Do While z < y <BR> a = a * 10<BR> y = y  1<BR>Loop<BR>b = a/c<BR>d = x/b<BR>e = left(d,3) & " MB"<BR>Response.Write(e)

AND THIS :)
<%<BR>x = 259<BR>y = (len(x)  1)<BR>z = 0<BR>a = y<BR>c = y<BR>Do While z < y <BR> a = a * 10<BR> y = y  1<BR>Loop<BR>b = a/c<BR>d = x/b<BR>e = replace(d,".",":",1,2)<BR>Response.Write(e)<BR>%&# 062;<BR>that would have to be altered a bit to have room for four digit times such as (ex 12:00)

Lets make our pages REALLY long :)
Hmmm... <BR>13 lines of code or just use my 1 line of code (which does cater for both 3 and 4 digit times). <BR><BR>I take your point about the Mb number, but if the answer has to be in Mb then my solution is still correct.<BR>

uhhhhh
i didn't see your time part... i just copied my Mb code and made it do time.<BR><BR>you must have read the threads from yesterday<BR><BR>and what would happen if the number to be converted was more digits then 4144089. they did say the number was coming from the database. so obviously it could vary. Ergo, 13 lines

Going for the longest thread
The Mb code would work for larger numbers without a problem. The only downside is if the number is less than 100000 as this would be evaluated as 0.0Mb.<BR><BR>By the way, what kind of a database stores times as 259 for 2:59 ? Now that is where the problem really lies!

RE: Going for the longest thread
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

