locked
Left Function does not work? RRS feed

  • Question

  • I expected the "Left" function in the code below to return the letter "A" but it returns nothing? Also, as a further test, Left(CP, 3) returns nothing?

    Any thoughts, ideas, suggestions, etc. will be much appreciated. Thanks,
    Joe Miller
           
    . . . .
    . . . .
    Dim CP As String
    CP = "ABCD"
    CP = Left(CP, 1)
    . . . .
    . . . .


    Joe MIller
    Sunday, October 31, 2010 4:33 PM

Answers

  • Joe,

    Try this:

        Dim CP As String
        CP = "ABCD"
        CP = Microsoft.VisualBasic.Left(CP, 1)
        Stop
    
    • Marked as answer by JCMJCM Sunday, October 31, 2010 5:11 PM
    Sunday, October 31, 2010 4:45 PM

All replies

  • Joe,

    Try this:

        Dim CP As String
        CP = "ABCD"
        CP = Microsoft.VisualBasic.Left(CP, 1)
        Stop
    
    • Marked as answer by JCMJCM Sunday, October 31, 2010 5:11 PM
    Sunday, October 31, 2010 4:45 PM
  • Wow!!!!! It worked. Never would have figured that one out, probably ever. Why is such nonsense necessary? Is there any way to eliminate the necessity of it? Not important, just wondering. 

    Anyhow, many thanks for the help - much appreciated. 

     

     

     

          


    Joe MIller
    Sunday, October 31, 2010 5:20 PM
  • Why is such nonsense necessary? Is there any way to eliminate the necessity of it?

    Well, you could try to use an imports statement so that you wouldn't need to fully qualify it, but I'm not sure here - doing that might give you an error indicating that one or more methods are ambiguous, but it wouldn't hurt but just to try it and see. Easy enough to remove it then go back to the fully qualified way of doing it.
    Sunday, October 31, 2010 6:46 PM