Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Left String in Procedure/Defined as Property 2

Status
Not open for further replies.

Christineeve

Programmer
Feb 12, 2005
104
US
Here is my code. In my IDE, "Left" appears as a Property and Integer, where "Mid" appears as Function is a String. Which it should be. I'm trying to figure out how can I find out why this Left is set as a Public Property.

I don't know how to find it and fix it. I know it's a stupid question, but I'm stuck on this. I appreciate your help.

Code:
Private Sub ReturnEnvironVarbls()
        Dim thePath As String = My.Application.GetEnvironmentVariable("Path")
        Dim myVariable As String = Environ("Path")
        Dim Counter As Integer
        Dim FullVariable As String
        Dim namePart As String
        Dim ValuePart As String
        Dim equalsPosition As Integer

        For Counter = 1 To 255
            FullVariable = Environ(Counter)
            If (FullVariable = "") Then Exit For
            equalsPosition = InStr(FullVariable, "=")
            If (equalsPosition > 0) Then

             [b]   namePart = Left(FullVariable, equalsPosition - 1)[/b]
                ValuePart = Mid(FullVariable, equalsPosition + 1)
            End If
        Next Counter
    End Sub
 
VB.Net is different than VB6. In VB6, you had built-in functions and constants provided to you. In .Net, these things are contained in namespaces within libraries.

So you can either make a call to Microsoft.VisualBasic.Left or use the preferred .Net libraries instead. Such as SomeStringVariable.SubString(Start, Length).
 
Thanks. It's weird that Mid works ok and left doesn't. Thanks for the help.
 
The reason that Mid works and Left doesn't is simply because .NET has an alternative use for Left and not for Mid.

Left, on a Form without a qualifier, is effectively converted, behind the scenes, to Me.Left (the Left side of "this" Form).
 
Thank you to both Softhemc and RiverGuy for your help. I gave stars to both of you for the answer to how and the answer to why. Thanks for patience with a Noob.

I changed my code to this and it works for my purpose. I'm sharing it for future inquiries.

Code:
         If (equalsPosition > 0) Then
                Dim namePart As String = Microsoft.VisualBasic.Left(FullVariable, equalsPosition - 1)
                ValuePart = Mid(FullVariable, equalsPosition + 1)
                Console.WriteLine("Environment Var: {0}", namePart)
                Console.WriteLine("Environment Var: {0}", ValuePart)
            End If

Thank you! Christine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top