Home All Groups Group Topic Archive Search About
Author
1 Jul 2006 7:10 AM
Domac
What happened with right function ??

What is it's substitute???

Author
1 Jul 2006 7:32 AM
Paul Remblance
> What happened with right function ??
>
> What is it's substitute???

May need to be fully qualified:

Microsoft.VisualBasic.Right
Author
1 Jul 2006 8:37 AM
Aristotelis Pitaridis
Private Function GetRight(ByVal InitialString As String, ByVal
NumOfChars As Integer) As String
        If InitialString.Length >= NumOfChars Then
            Return InitialString.Substring(InitialString.Length -
NumOfChars, NumOfChars)
        Else
            Return InitialString
        End If
    End Function

Aristotelis

Show quoteHide quote
Ï "Domac" <d*@dd.cc> Ýãñáøå óôï ìÞíõìá
news:ubXvi1NnGHA.2364@TK2MSFTNGP02.phx.gbl...

>
> What happened with right function ??
>
> What is it's substitute???
>
Author
1 Jul 2006 11:20 AM
Herfried K. Wagner [MVP]
"Domac" <d*@dd.cc> schrieb:
> What happened with right function ??

It's still there, as in VB6.

> What is it's substitute???

'Microsoft.VisualBasic.Strings.Right' = 'Right' :-).

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
1 Jul 2006 8:28 PM
Göran_Andersson
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
ArgumentException(Utils.GetResourceString("Argument_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:
Show quoteHide quote
> What happened with right function ??
>
> What is it's substitute???
>
>
Author
2 Jul 2006 6:19 AM
Cor Ligthert [MVP]
> 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
Author
2 Jul 2006 12:43 PM
Herfried K. Wagner [MVP]
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
>> 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/>
Author
2 Jul 2006 5:56 PM
Göran_Andersson
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.VisualBasic library. The code that I
posted is how the actual Right method is implemented.
Author
2 Jul 2006 6:57 PM
Cor Ligthert [MVP]
Goran,

Than I won't call this "It's just a wrapper", for me this is a wrapper plus
something extra.

Cor

Show quoteHide quote
"Göran Andersson" <gu***@guffa.com> schreef in bericht
news:eftTPDgnGHA.3784@TK2MSFTNGP04.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.VisualBasic library. The code that I
> posted is how the actual Right method is implemented.
Author
3 Jul 2006 10:19 AM
Göran_Andersson
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:
Show quoteHide quote
> 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" <gu***@guffa.com> schreef in bericht
> news:eftTPDgnGHA.3784@TK2MSFTNGP04.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.VisualBasic library. The code that I
>> posted is how the actual Right method is implemented.
>
>