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!

Extract portion of a string

Status
Not open for further replies.

dixxy12

Technical User
Jun 18, 2007
45
CA
Hello,

I am trying to extract a portion of text from a string but having some difficulty.

Here is how it goes:

the fiels name is [Parameters] which contains a very long text string, every value is split with a "|", and has an "=" with a value.
ei: ...|LABOR=15.00000|...
inside that string i am looking for specific words.
ei "LABOR="
what i would like to do is extract that the value for that specific word.
ei: 15.00000

here is what i am trying with no success:

Code:
labor3: InStr([parameters],InStr([LABOR],"="))
this returns a position I beleive not the value i am looking for
Code:
Labor: Mid([Parameters],InStr([Parameters],"LABOR"),5)
this returns a portion of the word "Labor"
Code:
test: Left(InStr("=",[Parameters],"Labor="),10)
this returns #error

what would be the correct syntax to accomplish this?

thanks,

Sylvain
 
Labor: Mid([Parameters],InStr([Parameters],"LABOR")+5)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
this is not giving me the correct result.

here is the string taht i am working with
Code:
BAND=#STET|TOTALLABOR=#M0.000000|PRICE=0.000000|LABOR=15.000000|_applyFD=#M
1.000000|RFDado=#M1.000000|HBORE_ON=#L1|MinThick=#M0.600000|HBoreDia=#M0.31
4961|HBoreDep=#M0.787402|BoreDia=#M0.314961|BoreDep=#M0.511811|BorePos=#M0.
316929|FixDowel1=#M1.259843|FixDowel2=#M2.519685|FixDowel3=#M7.559055|FixDo
wel4=#M10.078740|FixDowel5=#M13.858268|FixDowel6=#M18.897638|FixDowel7=#M24
.094488|FixDowel8=#M29.133858|FixDowel9=#M34.173228|FixDowel10=#M39.212598|
FixDowel11=#M44.251969|Pad=#M0.393701|PTTOTSDis=#M3.000000|FD_Left_Edge=#L0
|FD_Right_Edge=#L0|Pre_Drill_Toggle=#B0|BDado_UBack=#B1|BDado_Unfin_Ends=#B
1|DadoDep=#M0.250000|ApplyRabbet=#M0.000000|RabbetWidth=#M0.500000|TenWid=0
.391975|FNLen=#M0.000000|RNLen=#M0.000000|FNPad=#M0.000000|RNPad=#M0.000000
|FitAdj=#M-
0.015000|FT_FitAdj=#M0.030000|FT_Fit_Align=#L1|DepAdj=#M0.032500|Orientatio
n=#L2|FT_Fit_Pos=#M0.000000|Extend_Front_Notch=#M0.000000|EXTEND_REAR_NOTCH
=#M0.000000|Lfbdlgth=#M12.000000|Rgbdlgth=#M12.000000

this is the result from that formula you gave me

Code:
LABOR=#M0.000000|PRICE=0.000000|LABOR=15.000000|_applyFD=#M1.000000|RFDado=
#M1.000000|HBORE_ON=#L1|MinThick=#M0.600000|HBoreDia=#M0.314961|HBoreDep=#M
0.787402|BoreDia=#M0.314961|BoreDep=#M0.511811|BorePos=#M0.316929|FixDowel1
=#M1.259843|FixDowel2=#M2.519685|FixDowel3=#M7.559055|FixDowel4=#M10.078740
|FixDowel5=#M13.858268|FixDowel6=#M18.897638|FixDowel7=#M24.094488|FixDowel
8=#M29.133858|FixDowel9=#M34.173228|FixDowel10=#M39.212598|FixDowel11=#M44.
251969|Pad=#M0.393701|PTTOTSDis=#M3.000000|FD_Left_Edge=#L0|FD_Right_Edge=#
L0|Pre_Drill_Toggle=#B0|BDado_UBack=#B1|BDado_Unfin_Ends=#B1|DadoDep=#M0.25
0000|ApplyRabbet=#M0.000000|RabbetWidth=#M0.500000|TenWid=0.391975|FNLen=#M
0.000000|RNLen=#M0.000000|FNPad=#M0.000000|RNPad=#M0.000000|FitAdj=#M-
0.015000|FT_FitAdj=#M0.030000|FT_Fit_Align=#L1|DepAdj=#M0.032500|Orientatio
n=#L2|FT_Fit_Pos=#M0.000000|Extend_Front_Notch=#M0.000000|EXTEND_REAR_NOTCH
=#M0.000000|Lfbdlgth=#M12.000000|Rgbdlgth=#M12.000000

it only trimmed a litle bit off the beginning of it.

Thanks for your Help,

Sylvain
 
What about this ?
Labor: Left(Mid(Parameters,InStr(Parameters,"|LABOR=")+7),InStr(Mid(Parameters,InStr(Parameters,"|LABOR=")+7),"|")-1)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
also trying this
Code:
Labor7: Mid([Parameters],InStr([Parameters],"LABOR="),Len("LABOR=15.000000"))
the problem here is taht at the beginning of the string there is a TOTALLABOR, and this function pick that one up instead of the one that i want.

How can i set it to the specific text that i want?

Thanks for your Help,

Sylvain
 
Did you try my suggestion timestamped 18 Feb 10 13:59 ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes,

and it seems like i can get it to do what i need.

Thank you for now, will keep working at it to get the rest of the query.





Thanks for your Help,

Sylvain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top