Get Environment Setting Method
The Get Environment Setting method returns the string setting that is assigned to an environment variable for a keyword in the environment table of the operating system. If it cannot find the value that you specify, then it returns a null string.
Format A
Environ[$](environment-string)
The return value for format A is the string that is associated with the keyword.
For information about the dollar sign, see Usage of the Dollar Sign.
Format B
Environ[$](numeric_expression)
The return value for format B is a string that uses the following format:
KEYWORD=value
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
environment-string |
The name of a keyword in the operating system. You must enter the value for this argument in uppercase. If you do not, then this method returns a null string (""). |
numeric_expression |
An integer for the position of the string in the environment table. For example, 1st, 2nd, 3rd, and so on. This method rounds the numeric expression to a whole number, if necessary. |
Example
The following example lists the strings from the operating system environment table:
Sub Button_Click
Dim str1(100)
Dim msgtext
Dim count, x
Dim newline
newline = Chr(10)
x = 1
str1(x) = Environ(x)
Do While Environ(x) <> ""
str1(x) = Environ(x)
x = x + 1
str1(x) = Environ(x)
Loop
msgtext = "The Environment Strings are:" & newline & newline
count = x
For x = 1 to count
msgtext = msgtext & str1(x) & newline
Next x
End Sub