Private Function GetRight(ByVal InitialString As String, ByVal
NumOfChars As Integer) As String
If InitialString.L ength >= NumOfChars Then
Return InitialString.S ubstring(Initia lString.Length -
NumOfChars, NumOfChars)
Else
Return InitialString
End If
End Function
Aristotelis
Ï "Domac" <dd@dd.cc> Ýãñáøå óôï ìÞíõìá
news:ubXvi1NnGH A.2364@TK2MSFTN GP02.phx.gbl...
[color=blue]
>
> What happened with right function ??
>
> What is it's substitute???
>[/color]
It's still there, as previous posters pointed out. It's just a wrapper
around the methods in the String class, though.
This is how it's implemented:
Public Shared Function Right(ByVal str As String, ByVal Length As
Integer) As String
If (Length < 0) Then
Throw New
ArgumentExcepti on(Utils.GetRes ourceString("Ar gument_GEZero1" , New
String() { "Length" }))
End If
If ((Length = 0) OrElse (str Is Nothing)) Then
Return ""
End If
Dim num1 As Integer = str.Length
If (Length >= num1) Then
Return str
End If
Return str.Substring(( num1 - Length), Length)
End Function
If you know that the values you use are sane, you only need the code
from the last line.
If you only want to check the contents of the end of the string, there
are neater methods in the string class.
If Right(str, 4) = ".jpg" Then
translates into:
If str.EndsWith(". jpg") Then
Domac wrote:[color=blue]
> What happened with right function ??
>
> What is it's substitute???
>
>[/color]
>It's still there, as previous posters pointed out. It's just a wrapper
>around the methods in the String class, though.
>
Goran are you sure of that?
>
Because AFAIK is there more times written that this is sometimes the
situation for Visual Basic functions, however not forever.
According to the formatting style the code posted by Goran has been
extracted using Reflector or a similar tool.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
>It's still there, as previous posters pointed out. It's just a wrapper
>around the methods in the String class, though.
>>
>
Goran are you sure of that?
>
Because AFAIK is there more times written that this is sometimes the
situation for Visual Basic functions, however not forever.
>
Cor
>
If I correctly interpret what you are trying to say, you are saying that
several times it has been written that some of the Visual Basic
functions are wrappers, but not all of them?
Just as Herfried suspected, I have used Lutz Roeder's .NET Reflector to
look at the code in the Microsoft.Visua lBasic library. The code that I
posted is how the actual Right method is implemented.
Than I won't call this "It's just a wrapper", for me this is a wrapper plus
something extra.
Cor
"Göran Andersson" <guffa@guffa.co mschreef in bericht
news:eftTPDgnGH A.3784@TK2MSFTN GP04.phx.gbl...
Cor Ligthert [MVP] wrote:
>>It's still there, as previous posters pointed out. It's just a wrapper
>>around the methods in the String class, though.
>>>
>>
>Goran are you sure of that?
>>
>Because AFAIK is there more times written that this is sometimes the
>situation for Visual Basic functions, however not forever.
>>
>Cor
>>
>
If I correctly interpret what you are trying to say, you are saying that
several times it has been written that some of the Visual Basic functions
are wrappers, but not all of them?
>
Just as Herfried suspected, I have used Lutz Roeder's .NET Reflector to
look at the code in the Microsoft.Visua lBasic library. The code that I
posted is how the actual Right method is implemented.
Yes, you are right, there is a bit of logic there also.
Perhaps "Not much more than a wrapper" would have been a more suitable
description.
Cor Ligthert [MVP] wrote:
Goran,
>
Than I won't call this "It's just a wrapper", for me this is a wrapper plus
something extra.
>
Cor
>
"Göran Andersson" <guffa@guffa.co mschreef in bericht
news:eftTPDgnGH A.3784@TK2MSFTN GP04.phx.gbl...
>Cor Ligthert [MVP] wrote:
>>>It's still there, as previous posters pointed out. It's just a wrapper
>>>around the methods in the String class, though.
>>>>
>>Goran are you sure of that?
>>>
>>Because AFAIK is there more times written that this is sometimes the
>>situation for Visual Basic functions, however not forever.
>>>
>>Cor
>>>
>If I correctly interpret what you are trying to say, you are saying that
>several times it has been written that some of the Visual Basic functions
>are wrappers, but not all of them?
>>
>Just as Herfried suspected, I have used Lutz Roeder's .NET Reflector to
>look at the code in the Microsoft.Visua lBasic library. The code that I
>posted is how the actual Right method is implemented.
Comment