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!

Instr 1

Status
Not open for further replies.

gooseriver

IS-IT--Management
Aug 4, 2006
93
CA
On my report I have a string value with a (test). I need to take the value between the "(" and ")" and store it into a stringvar..

How can I do this so that the value in stringvar var1 is test?
 
I tried the folowing and my resuly was left with a ). In this case I used replace function to replace ) with a space... Is there a better way to do this?

If Instr({table1.field1},'(') <> 0 Then
strReverse(Split(strReverse({table1.field1}),'(')[1])
Else
{table1.field1}
 
Try the following

stringvar sTest := "gturteteey(test)sdfytu";
stringvar sResult := "";

if instr(sTest,"(") > 0 and instr(sTest,"(") > 0 then
sResult := mid(sTest,instr(sTest,"(")+1,(instr(sTest,")")-instr(sTest,"("))-1)
else
sTest
 
I think there is a slight typo on second 'instr' test in the 'if' statement. Cool formula jambu.

stringvar sTest := "gturteteey(test)sdfytu";
stringvar sResult := "";

if instr(sTest,"(") > 0 and instr(sTest,")") > 0 then
sResult := mid(sTest,instr(sTest,"(")+1,(instr(sTest,")")-instr(sTest,"("))-1)
else
sTest

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top