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 2590
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("00000000 0" & 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**********@h otmail.com> wrote in message
news:OE******** ******@TK2MSFTN GP10.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*******@yaho o.com> wrote in message
news:uu******** *****@tk2msftng p13.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("00000000 0" & i,9)
newstring = Right("0000000" & i,8)
;-p
I'd put it in a function.
Function PadInt(iNum, iPadLength)
PadInt = Right(String(iP adLength, "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" <hohmannATyahoo DOTcom> wrote in message
news:OA******** ******@TK2MSFTN GP10.phx.gbl... "Bob Barrows" <re*******@yaho o.com> wrote in message news:uu******** *****@tk2msftng p13.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("00000000 0" & i,9)
newstring = Right("0000000" & i,8)
;-p
"Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
news:Oh******** ******@tk2msftn gp13.phx.gbl... I'd put it in a function.
Function PadInt(iNum, iPadLength) PadInt = Right(String(iP adLength, "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(iP adLength - 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., etc.
The intent is to finish by assigning the list to a string that I would
write to disk: recstr = string.join(recd,'')
|
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. Unfortunately there is case where the string can be '\0\0'
Is this a defined bahavior when you do this kind of operation :
const char *s = "\0\0";
|
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 tbl_04_Hellenic.
Then In that form some of data also goes and fills another table call
tbl_LEHTAR.
Here is my code:
|
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 Clients INNER JOIN ServiceEvents ON
Clients.AutoID=ServiceEvents.AutoID
WHERE ServiceEvents.Sub=False;
Now, this looks fine when I few the query, and the "Unit" field is 4
| |
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
==== === ======
Ken 23 New York City
Rebecca 25 Toronto
|
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?
thanks!
|
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 this function)
|
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 href='".$file_name."&order_by=carnumber'>Carnumber</a></th>
<th><a href='".$file_name."&order_by=location'>Location</a></th>
<th><a href='".$file_name."&order_by=sighting_date_asc'>Sighting
Date</a></th>
<th><a href='".$file_name."&order_by=classification'>Code</a></th>...
|
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,...
|
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...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |