ilogic VBA InStrRev not reversing

ilogic VBA InStrRev not reversing

cbn56B4Z
Enthusiast Enthusiast
849 Views
4 Replies
Message 1 of 5

ilogic VBA InStrRev not reversing

cbn56B4Z
Enthusiast
Enthusiast

i want it to find the project folder and the project name, so i tell it to find the constant value (427, our office number)

but for some strange reason  InStr and InStrRev both return the same number rather than reversing the search direction. what's wrong with my code?

 

'dims
oPath = ThisDoc.Path

'get base project folder placement
oGet01 = InStr(oPath, "427")-1
oSet01 = Left(oPath, oGet01)
'get project name
oGet02 = InStrRev(oPath, "427")-1
oSet02 = Right(oPath, oGet02)
oGet03 = InStr(oSet02, "\")
oSet03 = Left(oSet02, oGet03)
MessageBox.Show("Get1: " & oGet01 & vbCrLf & "Set1: " & oSet01 & vbCrLf & "Get2: " & oGet02 & vbCrLf & "Set2: " & oSet02 & vbCrLf & "Get3: " & oGet03 & vbCrLf & "Set3: " & oSet03)

 

0 Likes
850 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Are you using iLogic or VBA?  Similar code exists in both environments, but they're not exactly the same.

See these links:

VB.NET versions

Strings.InStr Method 

Strings.InStrRev(String, String, Int32, CompareMethod) Method 

VBA versions

InStr function 

InStrRev function 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

JhoelForshav
Mentor
Mentor

Hi @cbn56B4Z 

Is the document you're running the rule in saved? Otherwise ThisDoc.Path will return an empty string..

 

Have you tried using the DesignProjectManager object?

Something like this maybe?

 

Dim oActiveProject As DesignProject = ThisApplication.DesignProjectManager.ActiveDesignProject

MsgBox("Workspacepath:	" & oActiveProject.WorkspacePath & vbCrLf _
& "Project name:	" & oActiveProject.Name)
Message 4 of 5

cbn56B4Z
Enthusiast
Enthusiast

@WCrihfield i'm using ilogic

@JhoelForshav sorry for the misunderstanding, but when i said project i did not literally mean project file, we run a single project folder via Vault, that project is split into years and then split into each "collection" i will call it instead, i need to get this "collection" number, not the project.

0 Likes
Message 5 of 5

cbn56B4Z
Enthusiast
Enthusiast

@WCrihfield i managed it wouthout InStrRev. using Mid instead

skimming the two InStrRev in iLogic 

InstrRev(stringcheck, stringmatch, [ start, [ compare ]])

InStr([ start ], string1string2, [ compare ])

they are basically the same, but they moved the [ start ] value.

if anybody knows of a reverse string search do tell.

 

anyways, here's my ugly solution for anybody who cares:

'dims
oPath = ThisDoc.Path

'get base project folder placement
oGet01 = InStr(oPath, "427")-1
oSet01 = Left(oPath, oGet01)
'get project name
oGet02 = InStr(oGet01 + 1, oPath, "\")-1
oSet02 = Left(oPath, oGet02)
oGet03 = InStrRev(oSet02, "\")
oSet03 = mid(oSet02, oGet03+1)
MessageBox.Show("Get1: " & oGet01 & vbCrLf & "Set1: " & oSet01 & vbCrLf & "Get2: " & oGet02 & vbCrLf & "Set2: " & oSet02 & vbCrLf & "Get3: " & oGet03 & vbCrLf & "Set3: " & oSet03)

 

0 Likes