Hi @Anonymous
I typically use the Split function for something like this. Here is an example that splits the string using the dashes
sMyString = "12345-01-001"
'split the string into an array using the dash
sMyArray = sMyString.Split("-")
'use the members of the array in a message box
MsgBox("the first bit is this: " & vbLf & sMyArray (0) )
MsgBox("the middle bit is this: " & vbLf & sMyArray (1) )
MsgBox("the last bit is this: " & vbLf & sMyArray (2) )
Here's another example using a backslash as the split characther, and it shows how to use UBound to find the upper bounds of the array, which in the case of a file path will always be the file name:
sMyString = "C:\TEMP\Test\11111-01\11-111.ipt"
'split the string into an array using the dash
sMyArray = sMyString.Split("\")
'use the members of the array in a message box
MsgBox("the first bit is this: " & vbLf & sMyArray(0) )
MsgBox("the next bit is this: " & vbLf & sMyArray(1) )
MsgBox("the next bit after that is this: " & vbLf & sMyArray(2))
'get the upper bounds of the array
'in this case it would be the file name
i = UBound(sMyArray)
MsgBox("the file name is this: " & vbLf & sMyArray(i))
'change the string
sMyString = "C:\TEMP\Test\111-1111\11111-01\111-1111\11111-01\11-111.ipt"
sMyArray = sMyString.Split("\")
'get the upper bounds of the array
'in this case it would be the file name
i = UBound(sMyArray)
MsgBox("Length of path changed, but we can still find the file name easily: " & vbLf & sMyArray(i))
Just a reminder, programming questions of this type are generally placed on the Inventor Customization forum :
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
I'll as the forum moderators to move this thread to that forum for you.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com