Globals.VariableValue[String] Eigenschaft

Definition

Gibt die Variable mit dem angegebenen Namen zurück oder legt diese fest.

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

Parameter

VariableName
String

Erforderlich. Eine Zeichenfolge, die den Namen der abzurufenden Variable darstellt.

Eigenschaftswert

Object

Ein Objekt, das die Variable darstellt.

Attribute

Beispiele

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()  
    Else  
        ' 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;  
    if(globals.get_VariableExists("GlobalsExample"))  
    {  
        // The counter has already been set, so increment it.  
        System.Int32 int32;  
        int32 = System.Int32.Parse((string)  
        globals["GlobalsExample"]);  
        int32++;  
        globals["GlobalsExample"] = int32.ToString();  
    }  
    else  
    {  
        // 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.");  
}  

Hinweise

Wenn Sie versuchen, eine Variable abzurufen, die nicht vorhanden ist, wird die Variable mit einem leeren Wert erstellt. Wenn Sie versuchen, eine Variable festzulegen, die nicht vorhanden ist, wird Sie mit dem angegebenen Wert erstellt.

Hinweis

VariableValue[] namens Zeichenfolgen dürfen keine Leerzeichen, Doppelpunkte (:) oder Punktzeichen (.) enthalten. Wenn ein Name eines dieser Zeichen enthält, erhalten Sie die Fehlermeldung "der Wert liegt nicht innerhalb des erwarteten Bereichs."

Gilt für