Strings and substrings

cBarry263

Active member
Joined
Oct 29, 2005
Messages
42
Location
Maryland
Programming Experience
Beginner
What's the .NET equivalent of the "Right" function in VB6. For example:
Imports System.String
.
.
.
Dim s as String
s = "example"
'Let's say I want to get rid of the "ex", in VB 6 you could do:
Dim temp as String
temp = Right(s, 2)

I'm trying to do something similar in .NET, but when I use the "Right" function, it says 'Public ReadOnly Property Right() As Integer' has no parameters and its return type cannot be indexed.
I know I have done this in .NET before, what's trick?
 
temp=s.substring(0,2)
[temp="ex"]
temp=s.substring(2)
[temp="ample"]

Do have a look at the "Basic String Operations" found in .NET Framework Developer's Guide. (both .Net 1 & 2 documentation)

You can also access the vb6 compability functions with the strings. keyword:
temp=strings.right(s,2)
The Strings module is from the microsoft.visualbasic namespace, but be aware that these functions are much slower than the string functions from native .Net Framework.
 
Back
Top