vb.net equivalent

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

What is the vb.net equivalent of;

y = Right(x, Len(x) - x.LastIndexOf("\"))

Thanks

Regards

PS: Trying to extract filename from the full path, in case anyone is
wondering.
 
Hi John,

Now where have I see that idea? ;-))

sFileName = sFilePath.Substring (sFilePath.LastIndexOf ("\") + 1)

Regards,
Fergus

ps. You could have asked in the same thread - we'd have seen it!
 
John,
I would recommend the 'System.IO.Path.GetFileName' function that Herfried
pointed out in the other thread.

Hope this helps
Jay
 
Hi

What is the vb.net equivalent of;

y = Right(x, Len(x) - x.LastIndexOf("\"))

Thanks

Regards

PS: Trying to extract filename from the full path, in case anyone is
wondering.

Imports System.IO

....

Dim fileName As String = Path.GetFileName(pathToFile)

HTH
 
I agree with the approaches below and think they are preferable, but you cna
use Microsoft.VisualBasic.Right(...) if you need to .

HTH,

Bill
 
* "John said:
What is the vb.net equivalent of;

y = Right(x, Len(x) - x.LastIndexOf("\"))

You may want to use 'Strings.Right' to avoid problems.
 
* "Jay B. Harlow said:
I would recommend the 'System.IO.Path.GetFileName' function that Herfried
pointed out in the other thread.

Thanks...

;-)
 
Hi Herfried, John,

Given that you know the starting point but not the number of characters:
Use Mid - save all the hassle with Len

Regards,
Fergus
 
Hi John,

I see everybody has to give you an answer

You can replace the fullpathname without the filename with "" if all other
things don't work Not that it is better, but again an alternative.

I never use that, but giving the same answer as the others is so easy.
:-))
Cor
 
* "Fergus Cooney said:
Given that you know the starting point but not the number of characters:
Use Mid - save all the hassle with Len

I wouldn't use the string functions for splitting the path at
all... 'System.IO' is better.

;-)
 
* "Cor said:
I see everybody has to give you an answer
ROFL

You can replace the fullpathname without the filename with "" if all other
things don't work Not that it is better, but again an alternative.

I never use that, but giving the same answer as the others is so easy.

Still ROFL.
 
Hi Herfried,

ROFL

I'm <sure> that's your name on the post that mentions Right()??

Regards,
Fergus
 
Hi Fergus,

He can go of from VB but never from his Right()s, with that I started a long
thread once with him. It was zero-zero, but that gave me the idea that you
could nice use your own favorites words in VB.

The same as in English the old Normandic or old Angel-Saxian words and
probably some Galic words.

:-))

Cor
 
Back
Top