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

Trim a string.

Status
Not open for further replies.

rayscott

IS-IT--Management
Oct 1, 2001
21
0
0
US
I have a string that is a follows. "short01*002"
how would i go about writing a formula to trim the string to only give me everything to the left of the "*". The string has no set size. It can be 5 characters long or 20 characters.
 
if Your string always contains a * then you can use a simple formula like this.

Left({MyField},Instr({MyField},'*')-1)

if a * is not present in the string then this will fail so you would need to use

NumberVar Position := Instr({MyField},'*')-1;

if position < 0 then
//do something here
else
Left({MyField},Position)

Hope this helps Gary Parker
Systems Support Analyst
 
Hi,

this line in your formula should do it...

Mid(YourString,1,InStr (YourString ,&quot;*&quot; ) - 1);

where YourString is the string containing &quot;short01*002&quot; or whatever.

Regards
Wayne


 
Try:

if Instr({MyField},'*') > 0 then
Left({MyField},Instr({MyField},'*')-1)
else
&quot;N/A&quot;

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top