Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Formatting a text string Post Reply Post New Topic
Author Message
fadopub
Newbie
Newbie


Joined: 23 May 2008
Online Status: Offline
Posts: 1
Quote fadopub Replybullet Topic: Formatting a text string
     Posted: 23 May 2008 at 12:47pm
Hi, I am new to this forum and was looking for some help in something our department is trying to do.  I am not a regular Crystal user, though I know some Visual Basic.  I think my problem is with my syntax I am using to obtain my output. 
 
We are creating a report to take a field that has the full name with the first and last name separate by a "/".  We need to take the part before the slash (fname) and the part after the slash (lname) and put these two results on the page under separate columns.  At the part where we right the formula for the fname and lname fields, we cannot figure out how to find which character place holds this slash to then trim what parts we need.  (Apologize for not using correct lingo). 
 
Knowing Visual Basic and referring to an example, I would write the code as follows.  I want to know how I can write this for Crystal to get our output.
 
Dim n As Integer
n = (Inventory.Traveler).IndexOf("/")
fname = (Inventory.Traveler).Substring(0, n)
lname = (Inventory.Traveler).Substring(n +1)
 
This is my line of thinking.  Any help at all would be appreciated on how to accomplish this.  We tried using "TRIM", but that only seems to work with spaces, not slashes. 
 
Thanks
IP IP Logged
andymc
Newbie
Newbie
Avatar

Joined: 17 Mar 2008
Location: United States
Online Status: Offline
Posts: 18
Quote andymc Replybullet Posted: 23 May 2008 at 3:28pm
Here's how I would do it (using Crystal Syntax):
 
stringvar array strng := split({Inventory.Traveler},"/");
 
// strng[1] is the first name
// strng[2] is the last name
Andymc
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum