Basically, I’m trying to do some string manipulation to edit directories.
I found some code to try and edit the directories, but when I use it it doesn’t recognise ‘right’ as being a function and only recognises it as a right property, thus producing an error.
I was wondering if there’s something I haven’t imported or if perhaps ‘right’ is an obsolete function that was used in VB6 but replaced with something.
The code I have is as follows:
Dim Foo As String
Dim Bar As String
Bar = 'some form of directory input i.e. my.computer.currentdirectory
Foo = right(Bar, (Len(Bar) - InStrRev(Bar, "/")))
MsgBox(Foo)
Ideally I need either a better method of manipulating directories or a way to get the ‘right’ functionality working.
Look up System.IO.Path – has lots of useful tools for this stuff. You’ll want GetDirectoryName and GetFileName especially. They work on directories as well as filenames.
http://msdn.microsoft.com/en-us/library/system.io.path.getfilename
http://msdn.microsoft.com/en-us/library/system.io.path.getdirectoryname