Results 1 to 7 of 7

Thread: Environ$

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    98
    ok folks - here it is: i am looking for a list of all the possible variables to be used with the Environ$("String") function. does anyone know a website where these are listed? or can anyone help direct me to a place where i might find information about this function? thanks a lot for all your help.

    Michael

  2. #2
    Guest
    Maybe you can find your info at the Microdudes Developer Network site. Ok i know it sometimes sucks, this site.
    But it also provide sometimes the info we need.


    http:\\msdn.microsoft.com.


    But here i have some information about the Environ function.

    /* ====================================================================

    Returns the String associated with an operating system environment variable.

    Syntax

    Environ({envstring | number})

    The Environ function syntax has thesenamed arguments:

    Part Description
    envstring Optional.String expression containing the name of an environment variable.
    number Optional.Numeric expression corresponding to the numeric order of the environment string in the environment-string table. The numberargument can be any numeric expression, but is rounded to a whole number before it is evaluated.


    Remarks

    If envstring can't be found in the environment-string table, a zero-length string ("") is returned. Otherwise, Environ returns the text assigned to the specified envstring; that is, the text following the equal sign (=) in the environment-string table for that environment variable.

    If you specify number, the string occupying that numeric position in the environment-string table is returned. In this case, Environ returns all of the text, including envstring. If there is no environment string in the specified position, Environ returns a zero-length string.

    /* ====================================================================

    Example:

    Code:
    Dim EnvString, Indx, Msg, PathLen   ' Declare variables.
    Indx = 1   ' Initialize index to 1.
    Do
       EnvString = Environ(Indx)   ' Get environment 
                ' variable.
       If Left(EnvString, 5) = "PATH=" Then   ' Check PATH entry.
          PathLen = Len(Environ("PATH"))   ' Get length.
          Msg = "PATH entry = " & Indx & " and length = " & PathLen
          Exit Do
       Else
          Indx = Indx + 1   ' Not PATH entry,
       End If   ' so increment.
    Loop Until EnvString = ""
    If PathLen > 0 Then
       MsgBox Msg   ' Display message.
    Else
       MsgBox "No PATH environment variable exists."
    End If
    Goodluck..

    -Kayoca Mortation

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    98
    thanks. i found that too on MSDN. it simply told me how to use it, which i know how to do. what i am looking for is a list of strings to use with the Environ$ function. for instance, in the above example you see Envorin$("PATH"). i want to know what other things i can use besides PATH. make sense? thanks a lot guys. and thanks to you kayoca. take care.

    michael

  4. #4
    Lively Member Ishamel's Avatar
    Join Date
    Nov 1999
    Location
    Edinburgh, Scotland
    Posts
    112
    I think this is what you are after.

    Code:
    Dim EnvString As String
    Dim Indx As Integer
    Dim myNewEnvironString As String
        
    Indx = 1   ' Initialize index to 1.
        
    Do
        EnvString = Environ(Indx)
          
        If Environ(Indx) <> "" Then
            'Search for the = character and read the left
            'section of the string.
            myNewEnvironString = Left(Environ(Indx), InStr(1, EnvString, "=") - 1)
            
            'Display the Environ Name
            Debug.Print myNewEnvironString
                
            Indx = Indx + 1  'Increment the index by 1
        End If
    Loop Until EnvString = ""

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Posts
    98
    thank you so very much ishmael. that's exactly what i was looking for. that's so great. thank you thank you thank you. ok...i'm done.

  6. #6
    New Member
    Join Date
    Mar 2011
    Posts
    1

    Post Re: Environ$ (Simplest method I know)

    Use the "set" command at a command prompt!


    Detailed Instructions:
    1. Open a Command Prompt window
      By default there is a shortcut in the start menu:
      • Vista/Win7: "Start -> All Programs -> Accessories"
      • Windows 95,98,XP "Classic Start Menu": "Start -> Programs -> Accessories"
    2. At the prompt, type "set" and press the 'Enter' or 'Return' key
    3. Let your eyes feast upon the glory that is all of the available options for environment variables (and their respective values)

  7. #7
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Environ$

    There is no complete list because users can define new ones any time they want.

    Be wary of user environment variables for many purposes like locating directories. These can be altered to false values whenever the user wants to.

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