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

How can I Strip a string from the middle of another string

Status
Not open for further replies.

JamesBBB

Technical User
Nov 2, 2005
74
GB
Hi All,

I have been trying to manipulate a string to pull out a specific part of the string, basically I have a set of directorys with the same number of path levels, like below

E:\Books\Fiction\Authors
E:\Books\Crime\Authors
E:\Books\Comedy\Authors

What I need to be able to do is pull out "Fiction","Crime","Authors" etc etc as a string.

"E:\Books" and "\Authors" are always the same.

I have tried using Mid, InStrRev etc, but I cannot get the syntax right to pull out the middle of the string as required.

If anyone could please show me how to do this I would be very grateful, as I am completly stuck.

many thanks

James
 
Code:
TheType = _
Replace ( Replace ( Path, "E:\Books\", "" ), "\Authors", "" )
 
Where strPath is your path, i.e. E:\Books\Fiction\Authors or
E:\Books\Crime\Authors or E:\Books\Comedy\Authors and Answer is your book genre:

Code:
Answer = Mid(strPath, 10, (Len(strPath) - 17))

will return Fiction or Crime or Comedy.

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top