You can assign returned property values to a variable. To do this, declare the variable using the data type for the property. (For properties that take Boolean or Enumeration values, declare the variable as an integer.) In this example, the variable is used to store the value of the Name property:

Dim productName As String

productName = Session.Name

You can also use a returned property value directly in a statement or expression, as in these examples:

Sub UsingReturnedPropertyValues ()

 With Session

  'Testing a boolean value

  If Not .Connected Then .Connect

  'Or the equivalent

  If .Connected = False Then .Connect

 

  'Modifying an existing value

  .Caption = .Caption & " Joe's Session"

 

  'Using a value in a message box

  MsgBox "The number rows in the display is " & .DisplayRows

 End With

End Sub