Right function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Domac

    #1

    Right function

    What happened with right function ??

    What is it's substitute???


  • Paul Remblance

    #2
    Re: Right function

    > What happened with right function ??[color=blue]
    >
    > What is it's substitute???[/color]

    May need to be fully qualified:

    Microsoft.Visua lBasic.Right


    Comment

    • Aristotelis Pitaridis

      #3
      Re: Right function

      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]


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Right function

        "Domac" <dd@dd.cc> schrieb:[color=blue]
        > What happened with right function ??[/color]

        It's still there, as in VB6.
        [color=blue]
        > What is it's substitute???[/color]

        'Microsoft.Visu alBasic.Strings .Right' = 'Right' :-).

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://classicvb.org/petition/>

        Comment

        • Göran Andersson

          #5
          Re: Right function

          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]

          Comment

          • Cor Ligthert [MVP]

            #6
            Re: Right function

            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


            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: Right function

              "Cor Ligthert [MVP]" <notmyfirstname @planet.nlschri eb:
              >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/>

              Comment

              • Göran Andersson

                #8
                Re: Right function

                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

                • Cor Ligthert [MVP]

                  #9
                  Re: Right function

                  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

                  • Göran Andersson

                    #10
                    Re: Right function

                    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

                    Working...