473,385 Members | 1,317 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

count digits

3
Hi Guys,

I need to make a pin like ADD - 00001 through ADD - 99999. I used the ID colomn in the table to generate this number like below:

<cfset #Pin# = #RIGHT('ADD - 0000'& #MyQuery.id#,13)#>

Now I have problem replacing the 0000 with numbers without loosing the 5 digit format. for example if the id value is 29 my pin should be ADD - 00029. any Idea?
Aug 6 '08 #1
5 3156
acoder
16,027 Expert Mod 8TB
Make a pad UDF which adds the required number of zeros and use that:
Expand|Select|Wrap|Line Numbers
  1. <cfset Pin = 'ADD - ' & pad(MyQuery.id,0,5)>
Aug 6 '08 #2
stoosi
3
Never mind. I fixed it. I'd love to post it if someone else has the same problem just let me know.
Aug 6 '08 #3
acoder
16,027 Expert Mod 8TB
Just post it anyway. You never know when it might prove useful to someone.
Aug 6 '08 #4
stoosi
3
I used very simple cfif statement and the same cfset as below;
Expand|Select|Wrap|Line Numbers
  1. <cfif #myQuery.id# LT 10 >
  2.         <cfset #Pin# = #RIGHT('ADD - 0000'& #myQuery.id#,16)#>
  3.      <cfelseif #MasterQuery.id# LT 100 >
  4.         <cfset #Pin# = #RIGHT('ADD - 000'& #myQuery.id#,16)#>
  5.       <cfelse>
  6.         <cfset #Pin# = #RIGHT('ADD - 00'& #myQuery.id#,16)#>
  7.       </cfif>
  8.  
But I'm working on your suggestion, because I saw it after I wrote my simple if statement. Here is the UDF so far. Thanks anyway.


Expand|Select|Wrap|Line Numbers
  1. function PadString(myQuery.id, 0, 5)
  2. {
  3.   Var Padding = RepeatString(0, 5);
  4.   return Padding & string;
  5. }
Aug 6 '08 #5
acoder
16,027 Expert Mod 8TB
You'll want to replace myQuery.id, 0 and 5 with variables. Also, your padding function won't work as desired because you've not made a check on the length of the string passed. You'll want to get the length of the string and subtract that from the pad-length to pass to RepeatString().
Aug 6 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Hunter | last post by:
Hi group - I'm using php to extract data from postgres and print to browser. I have data that was input through checkboxes on a form - each checkbox had a different value but got pushed into the...
8
by: Michael | last post by:
I have this script that works the way I want except for one thing... Once it hits zero it starts to count up and looks like this: -1:0-1:0-1:0-18 with the last number counting up. Can anyone...
4
by: grocery_stocker | last post by:
#include <iostream> //for cin and cout #include <iomanip> // for setw() #include <string> // for strlen() strcmp() strrev() #include <fstream> //ifstream and ofstream: file (input & output)...
68
by: Martin Joergensen | last post by:
Hi, I have some files which has the following content: 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0
2
by: Sathyaish | last post by:
I have a CSV file like so: "HDR",20060629133932,"9845","9083","0010" 1,"3","000000000690","000007","rsM4hJXR5Ik0O8RWghjtDBlUVAOZq7tO","BAR","0010","","",20.00...
5
by: JimmyKoolPantz | last post by:
for some reason I can't seem to figure this out. Situation: I'm using vb.net to create a query that will populate a dataset with zipcode and count that have unique first 3 digits. I want to...
2
by: HeroinNO.4 | last post by:
Copy the code below and save in a .htm file, for example : 1.htm, then run it in browser, you'll see a cool count down timer ! If it doesn't work, you may open http://www.fillweb.com in IE and...
2
by: Smokey Grindle | last post by:
any fast way to do this? I just need to check if if a string which could have a lot of characters in it if it has numbers and count the number of numbers in the string. thanks!
8
by: bettina top | last post by:
how can i count the digits of number given by the user
1
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.