Hi,
I have a counter i
Now I want to derive a fixed lenght string from this counter :
1 -> "00000001"
52 -> "00000052"
12896 -> "00012896"
What is the fastest way to do this?
This is part of a recursive subroutine, so the command will be executed
quite a lot.
Any suggestions?
tia
bartp
--
==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
========================================== 5 2577
bart plessers wrote: Hi,
I have a counter i Now I want to derive a fixed lenght string from this counter : 1 -> "00000001" 52 -> "00000052" 12896 -> "00012896"
What is the fastest way to do this? This is part of a recursive subroutine, so the command will be executed quite a lot.
Any suggestions?
tia
bartp
newstring = right("000000000" & i,9)
hmmmm
use len perhaps. you want 8 digits
my_len = len(my_counter)
my_len = 8 - my_len
for a = 1 to my_len
my_prefix = my_prefix & "0"
next
response.write my_prefix & my_counter
something like that would do it
i'm sure ray will have a one line solution, but he is heading for deity
status and i'm not
:P
jason
"bart plessers" <ba**********@hotmail.com> wrote in message
news:OE**************@TK2MSFTNGP10.phx.gbl... Hi,
I have a counter i Now I want to derive a fixed lenght string from this counter : 1 -> "00000001" 52 -> "00000052" 12896 -> "00012896"
What is the fastest way to do this? This is part of a recursive subroutine, so the command will be executed quite a lot.
Any suggestions?
tia
bartp
--
========================================== Hyper A.R.T. bart plessers Paul Van Ostaijenlaan 4 3001 Heverlee BELGIUM tel: +32 (16) 23.40.85 fax: +32 (16) 23.41.06 ==========================================
"Bob Barrows" <re*******@yahoo.com> wrote in message
news:uu*************@tk2msftngp13.phx.gbl... bart plessers wrote: Hi,
I have a counter i Now I want to derive a fixed lenght string from this counter : 1 -> "00000001" 52 -> "00000052" 12896 -> "00012896"
What is the fastest way to do this? This is part of a recursive subroutine, so the command will be executed quite a lot.
Any suggestions?
tia
bartp
newstring = right("000000000" & i,9)
newstring = Right("0000000" & i,8)
;-p
I'd put it in a function.
Function PadInt(iNum, iPadLength)
PadInt = Right(String(iPadLength, "0") & Cstr(iNum), iPadLength)
End Function
Response.write PadInt(34234, 8)
:P
Ray at home
--
Will trade ASP help for SQL Server help
"Chris Hohmann" <hohmannATyahooDOTcom> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl... "Bob Barrows" <re*******@yahoo.com> wrote in message news:uu*************@tk2msftngp13.phx.gbl... bart plessers wrote: Hi,
I have a counter i Now I want to derive a fixed lenght string from this counter : 1 -> "00000001" 52 -> "00000052" 12896 -> "00012896"
What is the fastest way to do this? This is part of a recursive subroutine, so the command will be executed quite a lot.
Any suggestions?
tia
bartp
newstring = right("000000000" & i,9)
newstring = Right("0000000" & i,8)
;-p
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:Oh**************@tk2msftngp13.phx.gbl... I'd put it in a function.
Function PadInt(iNum, iPadLength) PadInt = Right(String(iPadLength, "0") & Cstr(iNum), iPadLength) End Function
Response.write PadInt(34234, 8)
In my prior post I was making a (overly) subtle point about wasting 0's.
Back in my day, we didn't even have 1's and 0's. We have to use l's and
O's and only the executives got keyboards. The rest of us had to tap out
binary on the keyboard port.
Function PadInt(iNum, iPadLength)
PadInt = Right(String(iPadLength - 1, "0") & Cstr(iNum), iPadLength)
End Function
-Chr15 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John F Dutcher |
last post by:
I use code like the following to retrieve fields from a form:
recd =
recd.append(string.ljust(form.getfirst("lname",' '),15))
recd.append(string.ljust(form.getfirst("fname",' '),15))
etc.,...
|
by: Spare Change |
last post by:
I am told that I can have a dynamic or static string array.
So if I declare
string dynamic;
How do I add elements to dynamic and resize it ?
|
by: Mathieu Malaterre |
last post by:
Hello,
I guess this might be a very dummy question, but I couldn't find an
answer in the group's archive.
I am reading DICOM files, and to store the string read I use
std::string....
|
by: Niyazi |
last post by:
Hi
I am trying to insert some value into SQL Server 2000 tables and I am keep
getting the "Input string was not in a correct format" error.
When user fills the Form it updates the table call...
|
by: Andrew |
last post by:
I run a fixed-width export based on a query, and the query looks like
this...
Clients.SSN, Clients.ClientID, ServiceEvents.SeviceDate,
CStr(Format(,"0000")) AS Servs, "28" AS SETTING,
FROM...
|
by: Magix |
last post by:
Hi,
I would like to replace title string into a file. My output file looks like
this:
Name Age Address
==== === ...
|
by: ywchan |
last post by:
I would like to convert a string to a fixed length
e.g. if fixed length = 10
'abc' -> ' abc'
'abcdefghijklm' -> 'abcdefghij'
Is there any simple function in C# can perform this operation?...
|
by: cdolphin88 |
last post by:
Hi,
I'm reading from a .dat file and I want to know the length of the
string .
I' using the stringRef.length () but the compiler said there was an
error
`stringRef' undeclared (first use...
|
by: JRough |
last post by:
I have used this function to create a string called $headers:
function GetHeaders($file_name){
return "<th><a href='".$file_name."&order_by=l_e'>L_E</a></th>
<th><a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |