ClassMicrosoft.VisualBasic.Interaction SyntaxDim result As String = Environ(expression)
DescriptionThe Environ function returns the value assigned to an operating-system environment variable. Usage at a Glance
ExamplePublic Sub LoadEnvironmentStrings( ) ' ----- Store all environment strings internally. Dim environmentEntries As New Collection Dim oneEntry As String Dim counter As Integer Dim parts As String( ) ' ----- Scan through each valid environment variable. counter = 1 Do ' ----- Get the next entry. oneEntry = Environ(counter) If (oneEntry = "") Then Exit Do counter = counter + 1 ' ----- Get the name and value parts. parts = Split(oneEntry, "=") ' ----- Store the variable in the collection. If (UBound(parts) = 0) Then environmentEntries.Add("(undefined)", parts(0)) Else environmentEntries.Add(parts(1), parts(0)) End If Loop MsgBox("Loaded " & environmentEntries.Count & " variable(s).") End Sub Version Differences
|