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

Replacing/searching/subset string handling

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
Ok lets say I have a string with %ImagePath%picture.jpg<br>or C:\ commands would enable me to do either of the following<br><br>1)replace the %...% with a string that the macro is for<br>2)extract the %...% for use with a Select..Case<br>3)see if the %...% exist in the string so i can replace it with the proper paths<br>4) anything else I might be missing as far as my goal goes. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
Hi Karl,<br><br>This will do 3) from yuor list above. You can search for a string within another string as well.<br><br>Dim SearchString, SearchChar, MyPos<br>SearchString =&quot;XXpXXpXXPXXP&quot;&nbsp;&nbsp;&nbsp;' String to search in.<br>SearchChar = &quot;P&quot;&nbsp;&nbsp;&nbsp;' Search for &quot;P&quot;.<br><br>' A textual comparison starting at position 4. Returns 6.<br>MyPos = Instr(4, SearchString, SearchChar, 1)&nbsp;&nbsp;&nbsp;<br><br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Please -- Don't send me email questions without posting them in Tek-Tips as well. Better yet -- Post the question in Tek-Tips and send me a note saying "Have a look at so-and-so in the thingy forum would you?"
 
thanks, the way I did it for now is multiple replace commands<br><br>mystr = replace(mystr, &quot;%ImagePath%&quot;, Image_Path)<br>mystr = replace(mystr, &quot;%UpdatePath%&quot;, SetupPath)<br><br>thing is , theres no more than 10 Macros, so I did it like this for now. what would be nice though is to have some kind of macro table, where %...% = ...<br>then i just do a single command to go through the string. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
hey! Replace! &lt;hits head on desk once or twice&gt; sounds like a good solution to me. (didn't even know there <b>was</b> as <FONT FACE=monospace>Replace</font> function to be honest) <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Please -- Don't send me email questions without posting them in Tek-Tips as well. Better yet -- Post the question in Tek-Tips and send me a note saying "Have a look at so-and-so in the thingy forum would you?"
 
I knew there was a replace function, used it once, just wansnt sure how effective it would be for my purpose of having multiple macros. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top