Answered by:
Leading zero for Recno()

Question
-
I have a simple vfp9 program
temp.dbf has 2 fields
no (2 digits) + name
I use the following code:
replace all no with recno()
It works perfectly except I want it to be 01, 02, 03 ...09 leading zero for the first 9 numbers.
Help.
Thanxs
Friday, October 8, 2010 4:12 PM
Answers
All replies
-
The "no" column seems to be numeric, so leading zeros are possible to define in a mask when displaying data:
BROWSE FIELDS no00=TRANSFORM(no, '@L 99'), name
Friday, October 8, 2010 4:42 PM -
Hi,
I assume you want to display the content of your table in your form mit leading zeros. And in that case you use the FORMAT property of your textbox.
txtNo.Inputmask = 99
txtNo.format = [L]
This displays leading zeros instead of spaces in the text box.
Gruss / Best regards -Tom 010101100100011001010000011110000101001001101111011000110110101101110011Friday, October 8, 2010 4:42 PMAnswerer -
If you would need the leading zero stored in the table then the no column must be of character data type and the REPLACE command must contain TRANSFORM() function.
BTW, why do you need to store information which is known for all records?
Friday, October 8, 2010 4:44 PM -
Hi CaleCrow,>> I want it to be 01, 02, 03 ...09 leading zero for the first 9 numbers.Numbers are numbers, and as such never have leading zeros. I assume that you need that leading zero just for display purposes, thus just put a "L" into the Format property and a "99" into the Inputmask property of your textbox (or the column of a grid).
wOOdy
Microsoft Visual FoxPro Technology Advisor
Microsoft "Most Valuable Professional" from 1996 to 2009
Visit my XING profile! Don't know what XING is?*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.Visual FoxPro: It's magic !
(¸.·``··*
Friday, October 8, 2010 4:47 PM -
I am just curious how do you all know CaleCrow uses some textboxes? :-)
- Proposed as answer by Tom BorgmannEditor Friday, October 8, 2010 5:00 PM
Friday, October 8, 2010 4:53 PM -
You're right,
he could also use a label :-))))
label.Caption = TRANSFORM(no, '@L 99')
OR
label.Caption = PADL(no,2,[0])
Gruss / Best regards -Tom 010101100100011001010000011110000101001001101111011000110110101101110011Friday, October 8, 2010 5:02 PMAnswerer -
Hey, I also pointed to the Grid.Column ;)
wOOdy
Microsoft Visual FoxPro Technology Advisor
Microsoft "Most Valuable Professional" from 1996 to 2009
Visit my XING profile! Don't know what XING is?*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.Visual FoxPro: It's magic !
(¸.·``··*
Friday, October 8, 2010 5:53 PM -
Okay I can make the field NO a 2 digit character field. (This program is a utility that creates a table for another program so I don't have a textbox or anything else. Right now the code I have is
repl all NO with recno()
If I change NO to a character field exactly what is the line exact line of code I need to insert. Where does the transform go????
Thanks.
Friday, October 8, 2010 6:42 PM -
-
Hmm, it not so good if you are not able to update the REPLACE command when the field data type changes...
I would recommend some VFP books, e.g.:
http://www.ml-consult.co.uk/books.htm
http://fox.wikis.com/wc.dll?Wiki~GoodVFPBooks
http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dstripbooks&field-keywords=foxpro&x=16&y=22Friday, October 8, 2010 9:00 PM