Job Postings
 Crystal Reports Forum : General Information : Job Postings
Message Icon Topic: Find letter type location in string Post Reply Post New Topic
Author Message
EVSchmidt
Newbie
Newbie
Avatar

Joined: 09 May 2019
Location: United States
Online Status: Offline
Posts: 4
Quote EVSchmidt Replybullet Topic: Find letter type location in string
    Posted: 10 Dec 2019 at 12:46pm
I am stumped and hope you can help.

I have a table of alphanumeric strings. The max length of each strings are 6 characters. There is at most one letter in each string. Its location within the string is inconsistent from record to record. The letter is never the first character. I would like to create a function in Crystal reports which will return the position of the letter within the string relative to the left side. 1 being the first character, 2 being the second etc. and 0 if no letters are found. Note: I do not know the actual letter in this string all I know is it not a number.

typical field looks like 102b02, 12d09, 9k12 etc.
for reference we can refer to the field name as {Inv.Bin}

ultimately I want to return the numbers to the left of the letters, but I can do this if I can find the position of the letters in each field.

I appreciate any help you can provide. Thank you all.
regards


Edited by EVSchmidt - 10 Dec 2019 at 12:47pm
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 11 Dec 2019 at 3:50am
This might work.  I makes an assumption that there is an non-numeric character.
numbervar i;

for i := 1 to len({somefield}) do (
if not(isnumeric(mid(somefield,i,1))) then exit for
);
left({somefield},i-1)

There maybe a better solution.


Edited by kevlray - 11 Dec 2019 at 3:54am
IP IP Logged
EVSchmidt
Newbie
Newbie
Avatar

Joined: 09 May 2019
Location: United States
Online Status: Offline
Posts: 4
Quote EVSchmidt Replybullet Posted: 11 Dec 2019 at 5:16am
I declared the I variable and it worked perfect. Thankyou so much for your help
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.015 seconds.