Results 1 to 7 of 7

Thread: Left() and right()

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Guess....i have wooden shoes, in my free time i sell tulips and I live in a huge windmill...
    Posts
    176

    Left() and right()

    Sometimes i seem to be able to use them without problems but sometimes they don't work? Can anybody tell me what im doing wrong? thnx
    JpEgy

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    well there is no left and right as part of the string class..you now have SubString with the parameters (startingposition, length)

    if you want to get left 2 characters..you say

    blah = thestring.Substring(0,2)

    to get the right 2 characters of a string

    blah = thestring.SubString(thestring.length - 2,2)

    left and right I believe are just part of the Microsoft.VisualBasic class which is there solely for some backwards comatability..I try to avoid it as you do everything you could do in VB with the new stuff the framework provides.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3
    Thelonius
    Guest
    Two ways:


    Left() = strString.SubString(0, length)
    Right() = strString.SubString((strString.length - <how many characters from the right you want to return>))

    you can also import the Microsoft.VisualBasic namespace and use the Left and Right functions.

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    boy are we ever on the same track..arent we Thelonius?

    nearly the exact same answer
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5
    Thelonius
    Guest
    And posted within seconds of each other.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Guess....i have wooden shoes, in my free time i sell tulips and I live in a huge windmill...
    Posts
    176
    OK i found it out :-) thank you very much guys!
    Last edited by JpEgy; Apr 16th, 2002 at 06:20 PM.
    JpEgy

  7. #7
    Another way you can do it from the way listed above is to do something similar to the following:

    Dim test As String = Microsoft.VisualBasic.Left( str as string, length as Integer)

    Dim test As String = Microsoft.VisualBasic.Right( str as string, length as Integer)

    Dim test As String = Microsoft.VisualBasic.Mid(str as string, Start as Integer, Length as Integer)

    Just providing another avenue of attack. Hope it helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width