What happend to Right & Left

Hi everyone

I just tried to manipulate some strings in VB.Net, but what happend to Left() and Right() and of course Mid(). It seems that these functions are gone, but which one can I use Or is there now a totaly diffrent concept behind i Thanks for some advices. .


Answer this question

What happend to Right & Left

  • FrancoA

    Maybe you can post here what you learned so that when someone sees this post marked as answered they can also see what the answer is. I believe what you have figured out is that you can use String.Substring now instead of Left and Right.  But maybe you did it another way Let us know.

  • Andrew Jacobs

    It seems that stringmanipulation is always a main topic.
    Left and Right are gone, but there are some new methods & functions wich are very helpful. There is first Substring(). But also :

    LastIndexOf() or Index() or Length() etc.

    Now you have to use them for getting the needed parameters to fill in the Substring(), if you don't have a fix lenght that you can use.
    So all you VB6 ! Learn to love the .Net Framework!

  • JamesMiles

    It is under the "Strings" namespace module (sorry):

    Strings.Left("Zac", 1)

    Here's a pic.


  • Flavio

    OK I got it Idea


  • joe_pool_is

    You should use String.Substring to replace all of those previous functions, for example:




        Dim myString As String = "Hello World"
        Dim newSring As String

        newString = myString.SubString(0,5)
        Debug.WriteLine(newString)

        newString = myString.Substring(6,5)
        Debug.WriteLine(newString)

        newString = myString.SubString(myString.Length - 2)
        Debug.WriteLine(newString)


     


    You should have the following output:

    "Hello"
    "World"
    "ld"

    Good Luck.

  • Webbtrad

    Thanks Joe - Got my info. from here:-
     http://msdn2.microsoft.com/en-us/library/05e63829.aspx.  
     Should this have ref. to use of String.Substring

  • Rschraeger

    Thanks Chaps.
    It's all in the Link I gave you above.
    By the way Zac - No Pic.

  • Mang

    Otherwise, depending on what version of VB.Net you are using, you could also use:


    Microsoft.VisualBasic.Left(STRING, INTEGER)

     

    String is the string variable that you want to reference and Int in the amount of chars that you need to show.

    Hope that helps. Im a newbie. :)


  • Winnipeg B

    I am a Newbie looking for info on Basic KeyWords. I too noticed that Left$ and Right$ are not available. However Mid$ is.  Doesn't this make Left$ and Right$ unnecessary
    LEN$ is also available. 

  • What happend to Right & Left