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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse number from a string 2

Status
Not open for further replies.

hallux

Programmer
Feb 25, 2003
133
US
Hi everybody,

Is there a Crystal function useful to extract the numbers from a string? The field has a room name followed by a room number "Dining Hall 01". All that is needed is the number "01".

Thanks,
Hallux
 
If the room number is always two digits, you can use:

right({table.string},2)

If the number can vary in length, then try this:

right({table.string}, len({table.string})-instrrev({table.string}, " "))

-LB
 
..and if you want to convert the output of lbass's formula to a number - use;

ToNumber({table.string,2)

Crystal will error out when the report is processed if any record has a value that cannot be converted to a number. To avoid this use;

if NumericText({table.string,2}
then
ToNumber({table.string,2}
else
0

Peter Shirley
 
Thank you lbass for a formula that worked perfectly for this situation and crystalreporting for a helpful tip w/ a method of checking for Numeric Text.
-Hallux
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top