Globals.VariableValue[String] Globals.VariableValue[String] Globals.VariableValue[String] Globals.VariableValue[String] Property


Returns or sets the variable with the specified name.

 property System::Object ^ default[System::String ^] { System::Object ^ get(System::String ^ VariableName); void set(System::String ^ VariableName, System::Object ^ value); };
[get: System.Runtime.InteropServices.DispId(0)]
[set: System.Runtime.InteropServices.DispId(0)]
public object this[string VariableName] { get; set; }
member this.VariableValue(string) : obj with get, set
Default Public Property VariableValue(VariableName As String) As Object
String String String String

Required. A string representing the name of the variable to retrieve.

Property Value

An object representing the variable.


Sub GlobalsExample(ByVal dte As DTE)  
    Dim globals As Globals  
    globals = dte.Solution.Globals  
    If globals.VariableExists("GlobalsExample") Then  
        ' The counter has already been set, so increment it.  
        Dim int32 As System.Int32  
        int32 = System.Int32.Parse(CStr(globals("GlobalsExample")))  
        int32 += 1  
        globals("GlobalsExample") = int32.ToString()  
        ' Counter has never been set, so create and initialize it.  
        globals("GlobalsExample") = 1.ToString()  
        globals.VariablePersists("GlobalsExample") = True  
    End If  
    MsgBox("This variable has been called: " & _  
    globals.VariableValue("GlobalsExample") & " times.")  
End Sub  
void GlobalsExample(_DTE applicationObject)  
    Globals globals;  
    globals = applicationObject.Solution.Globals;  
        // The counter has already been set, so increment it.  
        System.Int32 int32;  
        int32 = System.Int32.Parse((string)  
        globals["GlobalsExample"] = int32.ToString();  
        // Counter has never been set, so create and initialize it.  
        globals["GlobalsExample"] = 1.ToString();  
        globals.set_VariablePersists("GlobalsExample", true);  
    System.Windows.Forms.MessageBox.Show("This variable has been called:   
    " + globals.VariableValue["GlobalsExample"] + " times.");  


If you attempt to retrieve a variable that does not exist, the variable is created with an empty value. If you attempt to set a variable that does not exist, it is created with the specified value.


VariableValue[String] name strings cannot contain space, colon (:), or period(.) characters. If a name has any of these characters, you get the error, "Value does not fall within expected range."

Applies to