Environment variables are a universal mechanism for conveying configuration information to programs. Let’s look at how to set, get, and list environment variables in Visual Basic .NET.
Running the program shows that we pick up the value for FOO that we set in the program, but that BAR is empty.
The list of keys in the environment will depend on your particular machine.
If we set BAR in the environment first, the running program picks that value up. In Visual Basic .NET, you can set environment variables before running the program using the command prompt:
Note that the exact method of setting environment variables and compiling/running the program may vary depending on your development environment and Visual Studio settings.