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

Extract Certain part of text 2

Status
Not open for further replies.

din2005

Programmer
Joined
Mar 22, 2005
Messages
162
Location
GB
Hi all i would like to extract certain section of text.

The text is

myfolder = "C:\TestImage\di2548\19Oct2001"

So far i can retrieve 19Oct2001 with this code

strFolderTreatDate = Mid$(myfolder, InStrRev(myfolder, "\") + 1)

How do i adapt this code so i can get di2548.


many thanks
 
Something like this ?
myfolder = "C:\TestImage\di2548\19Oct2001"
Dim myArr
myArr = Split(myFolder, "\")
strFolderTreatDate = myArr(UBound(myArr))
strFoldersubFolder = myArr(UBound(myArr) - 1)
MsgBox myfolder & vbCrLf & strFoldersubFolder & vbCrLf & strFolderTreatDate


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Many thanks PHV for replying,

i get error msg when i use the split function and it highlight the code where its causing the problem (i've highlighted it in red).

The error msg i get is:

Compile error:
Type mismatch: array or user defined type expected

Am using windows xp and Access 2003 could this be a refence problem or something.


myfolder = "C:\TestImage\di2548\19Oct2001"
Dim myArr
myArr = Split(myfolder, "\")
strFolderTreatDate = myArr(UBound(myArr))
strFoldersubFolder = myArr(UBound(myArr) - 1)
MsgBox myfolder & vbCrLf & strFoldersubFolder & vbCrLf & strFolderTreatDate



 
Have you somewhere in the code Split already defined ?
You may try this:
myArr = VBA.Split(myfolder, "\")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Soon as i tried vba.split it worked to certain point but having tried myArr() as string it compiles successfully. cheers guys. Stars for both of you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top