Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last Part of String

Status
Not open for further replies.

GMAN33

IS-IT--Management
Dec 4, 2002
115
US
Hi All

I have a DB field that has data in it like

PAGE 01
PAGE 02
PAGE 10
PAGE 121
PAGE 200

I need to get just the number part of this but also eliminate the leading 0 on the data
PAGE 01 to PAGE 09 so that I just get 1, 2, 3, etc

I am using

replace({table.field name},"PAGE 0","");

this works but it is not working on the PAGE 10, PAGE 121, etc

Any ideas or help
Thanks
 
How about

ToNumber(replace({table.field name},"PAGE ",""))

Just strip the "Page" part and then convert what's left into a number field, which won't have any leading 0s.
 
The way I have done this in the past is to use a while do formula test on the data.

whileprintingrecords;

local numbervar n:= 1
local numbervar len:= length(fieldname)

while right(fieldname, n) <> " " do
(n:=n+1;);

tonumber(mid(fieldname, (len-n), n));

the tonumber function should lose the leading zero.

Ian



 
Or you could use:

val(mid({table.string},6))

-LB
 
Thank you guys

The first suggestion, I get an error that states

"The string is non-numeric"

The second suggestion states

Something about the loop went on for too long

The third suggestion comes back somewhat ok, however, there are is ".00" after each record

Thanks again for the very quick response

 
Select the result of my formula and then click on the decrease decimals icon in the toolbar.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top