Formatting strings in CR 6

I´m using Crystal Reports 6 and I want a string to be display in a specific format (for example "123456" should look like "12 34 56"). How do I do that?
Who is Participating?
JuiletteConnect With a Mentor Commented:
'example of showing a formatted phone number
'by building a formula in crystal reports

'start number = 1234567890
'after formula = (123)-456-7890

'insert it...PhoneNumber
'the basis of the formula is:

'Pcode is the name of my variable I am assigning to StringVar
'punctation is important...(:=) and at end (;)

'StringVar PCode := [your character] + [tablename.fieldname][number of 'characters from  startnumber or alpha sting] + [your character] ;

StringVar PCode := "(" + {Phone.HomePhone}[1 to 3] + ")-";
StringVar PCode3 := {Phone.HomePhone}[4 to 6] + "-";
StringVar PCode4 := {Phone.HomePhone}[7 to 10] ;
PCode + PCode3 + PCode4

'in the end we just join the three strings we have created
'and we end up with a formatted phone number (123)-456-7890
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.