Environ()

J

Jan Kronsell

Is there anywhere I can find a list of the Environment numbers I can use
with the Environ statement. like Environ(13) gives me the number of
Processors.

I have seach the VBA help wih no luck so far.

Jan
 
J

Jan Kronsell

I have to add, that I have created the list myself, i just wondered if it
could be found anyywhere

Jan
 
B

Bob Phillips

Jan,

There is no set list as it will depend upon what environment variables have
been set on each particular machine.

Here is some code to print it all out

Dim iLoop As Long

iLoop = 1
Do
Debug.Print "#" & Format(iLoop, "00") & " " & Environ(iLoop)
iLoop = iLoop + 1
Loop Until Environ(iLoop) = ""


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
J

Jan Kronsell

Hi Bob

Thanks. I made the list myself using similar code to yours. I just wondered
if a list of possible values to be checked for existed.

Jan
 
R

Rob van Gelder

The Environ "list" can be referenced by number so you can check the list
from start to finish.

You can also check for the environment variable by name directly:
eg. MsgBox Environ("NUMBER_OF_PROCESSORS")


This code checks for the existence of the environment variable
Sub test()
Dim blnExists As Boolean, strSearch As String
strSearch = "NUMBER_OF_PROCESSORS"

blnExists = (Environ(strSearch) <> "")

MsgBox blnExists
End Sub
 
J

Jan Kronsell

Thanks!

Jan

Rob van Gelder said:
The Environ "list" can be referenced by number so you can check the list
from start to finish.

You can also check for the environment variable by name directly:
eg. MsgBox Environ("NUMBER_OF_PROCESSORS")


This code checks for the existence of the environment variable
Sub test()
Dim blnExists As Boolean, strSearch As String
strSearch = "NUMBER_OF_PROCESSORS"

blnExists = (Environ(strSearch) <> "")

MsgBox blnExists
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top