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

Crystal - Trimming 2

Status
Not open for further replies.

DOMAL

Technical User
Apr 12, 2007
30
GB
Hi

I need help with the 'trim' function, cant get it to work in crystal 8.5

I get "TrimLeft ()"

Now I need to trim a string that is system generated, not a calculated field by 5 characters from the left.

Please help!

Thanks
 
Do you mean you need to 'trim' (Remove spaces from either or both ends of the string) or do you want to remove the first 5 characters regardless of spaces?

Some examples and their outputs:

//{@teststring}

' AAAAABBBBBCCCCC '

//{@Trim}
trim({@teststring})

'AAAAABBBBBCCCCC'

//{@Trimleft}
trimleft({@teststring})

'AAAAABBBBBCCCCC '

//{@Trimright}
trimright({@teststring})

' AAAAABBBBBCCCCC'

//{@remove1stfive}
mid({@teststring},6,len({@teststring})

'ABBBBBCCCCC '

//{@trimandremove1stfive}
mid(trim({@teststring}),6,len({@teststring})
'BBBBBCCCCC'

//{@trimanddisplay1stfive}
left(trim({@teststring}),5)
'AAAAA'


Does the above make sense? If you want to try out different displays then just test some of the above formulas with your own strings to see how they are affected. There are other solutions also but I am trying to understand your sample data and required output without much luck at the moment.

If you could post some sample data and desired layout then it would help to answer the question for yourself and any other users stumbling over the same issue :)

'J
 
Thanks for your reply!

That helps alot, I was struggling to understand how crystal wanted the formula layed out!

I have a system string {slscmtrix_reference} which is an invoice number 0000024566 (for example).

I want it to display 24566 without the 0's at the start.

I've not tested your response yet but it looks great to me, thanks!
 
Val() or tonumber() will work for what you want. Val() will work with alphanumeric strings what start with a number:

Val("1234 S Main Street") will return the number 1234. Tonumber() would error out on this.

Hope this helps.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top