Results 1 to 7 of 7

Thread: LEFT Function?

  1. #1
    jmancuso is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Feb 2005
    Posts
    22
    Reputation
    121

    LEFT Function?

    Okay, just learning VB .NET migrating from VBA and VB 6.0. This should be super easy but I cant seem to get the LEFT Function to work. Does VB .NET support this?

    Thanks.

  2. #2
    cjaymcmeans is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jan 2005
    Posts
    85
    Reputation
    123
    have you tried using
    microsoft.visualbasic as an import??

    if no, then try adding it as imports...

    if you have then what are you trying to do and can you give me some more details as to what it is that your try to accomplish...

    regards
    cjay
    We who are not as Others....

  3. #3
    Paszt's Avatar
    Paszt is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2004
    Location
    Raleigh, NC - USA
    Posts
    1,500
    Reputation
    325
    Importing the namespace isn't necessary. The Imports statement is a sort of shortcut so that you don't have to type the namespace again and again. Although it would work.
    You could do something like this:
    Code:
    Dim str As String = Microsoft.VisualBasic.Left("Test", 2) ' str = "Te"
    The more .NET way of doing that is to use the SubString Function of the String class. The above code would become:
    Code:
    Dim str2 As String = "Test".Substring(0, 2)  ' str2 = "Te"

  4. #4
    jmancuso is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Feb 2005
    Posts
    22
    Reputation
    121
    Thank you for all the input on this. I figured out how to get it working using

    Microsoft.VisualBasic.Left(string,2)

    And thank you for the info on the substring function!!!

  5. #5
    Neal's Avatar
    Neal is offline VB.NET Forum Admin
    .NET Framework
    .NET 4.5
    Join Date
    Jul 2004
    Location
    Richmond, VA
    Posts
    1,250
    Reputation
    239
    You should use the new .SubString method, for example:

    Dim MyValue As String
    MyValue = Whatever.SubString(0,2)
    Neal
    VB.NET Forums Admin

  6. #6
    SpiritualMachine is offline VB.NET Forum Newbie
    .NET Framework
    Join Date
    Feb 2005
    Posts
    12
    Reputation
    121
    I use Strings.Left(...

  7. #7
    kulrom's Avatar
    kulrom is offline VB.NET Forum All-Mighty
    .NET Framework
    .NET 3.5
    Join Date
    May 2005
    Location
    Republic of Macedonia
    Posts
    2,855
    Reputation
    266
    Quote Originally Posted by SpiritualMachine
    I use Strings.Left(...
    Well, if you want to work with vb.net then don't use the Left function for manipulating strings ... but rather use Substring method for the same.

    Cheers

Bookmarks

Posting Permissions

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