View Full Version : Format number....
Haddok
10-04-2002, 12:08 PM
I have the filename: Example_0001.doc
I can slice it into these parts:
(1) example_
(2) 0001
(3) .doc
After manipulatin (2) I build the string again so I get the filename: Example_0002.doc and so on.
My problem is that I want to manipulate (2) without loosing the 000..... My result now when rebuilding the filename is: Example_2.doc. Is it possible to format (2) so that is has to be a four digit number? (After a hundred operations the filename should be: Example_0100.doc)
I hope I'm clear about my problem... And it has to be done in ASP.
dlconnor
10-04-2002, 12:58 PM
<%@ language=VBScript%>
<%
sub strFill(str1,fill,num,str2)
str2 = ""
for i = 1 to num
str2 = str2 & fill
next
str2 = str2 & str1
end sub
%>
<html><head></head>
<body bgcolor="00224C" text="white" link="white" vlink="white" alink="white">
<% dim test,outstr
test = "2"
call strFill(test,"0",2,outstr)
%>
<font size=5><b><%=outstr%></b></font>
</body></html>
rcreyes
10-16-2002, 05:35 PM
Another solution is by using the Right function as follows:
<%
DocID=2
FormatedDocId = Right("0000" & DocId,4)
Response.Write FormatedDocId
%>
whammy
10-17-2002, 12:29 AM
Duh... why didn't I think of telling him that? I use it all the time!!! Good answer.
Haddok
10-17-2002, 09:10 AM
...but...
I have a really weird problem with the server (that I'm trying to work my way around).
First an update:
now the filename looks like this Example[0.01].doc where 0.01 is the version number of the document uploaded.
Weird problem:
When anyone is logged in on the server, the caluculation
Fileversion = Fileversion + 0.01 returns Fileversion = 0.02, which is OK.
Now, when no one is logged in on the server
Fileversion = Fileversion + 0.01 returns Fileversion = 1,01, which is NOK. For some reason the server(?) interprete 0.01 as 1.... And ONLY if no one is logged in.... (reading 0.01 from database and resp.write works ok)
has anyone a clue about why this happens???
/Cheers
Haddok
10-17-2002, 09:24 AM
I have solved my problem like this:
intFileversion = objRS("Version")
intApprovedVers = Left(intFileversion, InStr(intFileversion,"."))
intFileversion = Right(intFileversion, InStr(intFileversion,"."))
intFileversion = Right("00" & (intFileversion+1),2)
intFileversion = intApprovedVers & intFileversion
But I'm still curious if you have experienced the same server-problem....
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.