What is the replacement for VB6's Right() function in VB.Net?
Printable View
What is the replacement for VB6's Right() function in VB.Net?
use the Substring function , eg:
VB Code:
Dim s As String = "test 123" MessageBox.Show(s.Substring(s.Length - 3))
That's fine. There are so many ways to achieve the result. But is there any built-in function in VB.Net?
I just wonder, why they removed such an useful function!!
What's with you guys:confused: :confused:
The Right function is still with us. Of course it cannot be used in any class which has a Right property (as with Left etc) such as a form but you then use
VB Code:
Microsoft.VisualBasic.Right
:bigyello: :bigyello: :bigyello:
Common taxes,
Everybody knows that.
But that's an additional reference to Microsoft.VisualBasic namespace.
What if I want to avoid it?
then you have to follow what sysop suggested .;)Quote:
Originally posted by pvbangera
What if I want to avoid it?
"Common taxes,
Everybody knows that. "
OK. I'll assume you know everything in future. Bye
The substring IS native to .net. It's the "proper" way of getting your results. you can use the right() function but i've HEARD through the grapevine that some older functions will lose portability when Whidbey comes around the mountain:)
well as i said use the Substring function , but whidbey hasn't lost the visual basic Right function ;) i run whidbey and this is straight from it ...
VB Code:
Dim s As String = "test 123" MessageBox.Show(Microsoft.VisualBasic.Right(s, 3))
Hi dynamic_sysop,
" MessageBox.Show(Microsoft.VisualBasic.Right(s, 3))"
So. This function already exists in VB.NET. What is all the fuss? VB.NET even allows you to use
MessageBox.Show(Right(s, 3))
in a module.
I thinx Taxes is too sensitive. That was a very rude "Bye"
Well, I think
VB Code:
MessageBox.Show(Right(s, 3))
needs
VB Code:
Imports Microsoft.VisualBasic
statement on top of your class.