Export (0) Print
Expand All
ID
Top
Expand Minimize

VariableExists Property

Visual Studio .NET 2003

Returns whether the indicated variable exists.

[Visual Basic .NET]
Public ReadOnly Property VariableExists( _
   ByVal Name As String _
) As Boolean
[Visual Basic 6]
Property Get VariableExists( _
   ByVal Name As String _
) As Boolean
[C++]
HRESULT __stdcall get_VariableExists(
   BSTR Name,
   /* [out, retval] */ VARIANT_BOOL* retVal
);
[C#]
public bool VariableExists(
   string Name
) {get;}
[JScript .NET]
public function get VariableExists(
   Name : String
) : Boolean

Parameters

Name
Required. Represents the name of the variable.

Return Value

True if variable exists, False if it does not.

Remarks

If you attempt to check the value of a variable with the VariableValue property and the variable does not exist, a new variable of that name is created with a null value. To distinguish between an empty variable and a nonexistent variable, use the VariableExists property.

Variables:

  • Have no limit as to length, other than system limitations.
  • Are case-insensitive.
  • Can contain any characters permitted by the system.
  • Are restricted to simple data types such as strings and numbers. No SafeArrays or IDispatches can be used.

Example

Private objSoln As Solution

Public Property prop(ByVal somestuff As String)
   Get
      objSoln.Globals.VariableValue("SampleProp") = somestuff
      objSoln.Globals.VariablePersists("SampleProp") = True
   End Get
   Set(ByVal SampleProp)
      If Not objSoln.Globals.VariableExists("SampleProp") Then
         objSoln.Globals.VariableValue("SampleProp") = ""
         objSoln.Globals.VariablePersists("SampleProp") = True
      End If
      SampleProp = objSoln.Globals.VariableValue("SampleProp")
   End Set
End Property

See Also

Applies To: Globals Object

Show:
© 2014 Microsoft