Get, then delete, parts of longer string

E

Ed

I have collected items and set them into a long string stored in a document,
with each item set off inside "<" and ">". So a final string might look
like <item 1><item 2><item 3>.

I know how to use InStr(string) to find the first ">". I was going to use
Mid to get the string from 2 (since I don't want the first "<") to InStr -
1, but Mid Help says it doesn't get the string - it replaces it. That's
fine - I will want to replace it with noting to delete it. But I need to
get it out of the long string first.

What do I use in between InStr and Mid? Or is there a better way?

Ed
 
K

Klaus Linke

Hi Ed,

There's both a Mid method and a Mid function. You looked at the help for the Mid method, but need the Mid function.

You can locate both the position of the next "<" and ">" with InStr, and then get the string using the Mid function (starting at the position of the "<", length equals the difference between both positions).

Regards,
Klaus
 
E

Ed

That's it, Klaus! Thank you!
Ed

Hi Ed,

There's both a Mid method and a Mid function. You looked at the help for the
Mid method, but need the Mid function.

You can locate both the position of the next "<" and ">" with InStr, and
then get the string using the Mid function (starting at the position of the
"<", length equals the difference between both positions).

Regards,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top