CB.SetDecVar

This function changes certain attributes for a decision variable without redefining the decision variable using CB.DefineDecVarND.

Table 174. CB.SetDecVar Returned Data Type

Returned Value

Returned Data Type

Whether the function was successful

Variant

Before you call this function, the decision variable must exist and the simulation must be reset.

Table 175. CB.SetDecVar Parameters

Parameter

VBA Data Type

Value

Description

DecVarReference

Variant

In a macro: Range("B3")

Points to the decision variable cell with the data to change

Index

Integer

See Table 176

Works with Value to set decision variable attributes

Value

Variant

See Table 177

Changes decision variable attributes specified with Index

Table 176, following, describes the Index parameter.

Table 176. CB.SetDecVar Index Parameter Values — Required, Integer

Named Constant Value

Index Value

Description

cbDecName

1

Changes the decision variable name according to Value

cbDecMin

2

Changes the minimum (lower) bound, according to Value

cbDecMax

3

Changes the maximum (upper) bound, according to Value

cbDecType

4

Changes the decision variable type, according to Value

cbDecStep

5

Changes the step size for discrete decision variables, depending on Value.

cbDecFrozen

6

Freezes the selected decision variable, depending on Value

cbDecCustomData

7

Supplies a list of possible values for cbDecType = Custom [4]. Decimals can be used

Table 177, following, describes the Value parameter.

Table 177. CB.SetDecVar Value Parameter Values — Required, Variant

Used With Specified Values of Index

Value

Description

For Index = 1, cbDecName: String

Decision variable name, in quotes ("")

Specifies the new decision variable name

For Index = 2, cbDecMin: Double

Any number

Sets the new minimum (lower) bound

For Index = 3, cbDecMax: Double

Any number

Sets the new maximum (upper) bound

For Index = 4, cbDecType: Integer

cbDecVarTypeContinuous = 0, cbDecVarTypeDiscrete = 1, cbDecVarTypeBinary = 2, cbDecVarTypeCategory = 3, cbDecVarTypeCustom = 4

For a detailed description of each of these cbDecType settings, see CB.DefineDecVarND. For cbDecVarTypeCustom, a string of data must be supplied with Index = cbDecCustomData [7].

For Index = 5, cbDecStep: Double

Any whole number smaller than the range and greater than 0

Sets the new step size for discrete variables

For Index = 6, cbDecFrozen: Boolean

True or False

True freezes the current decision variable. False unfreezes it, if frozen

For Index = 7, cbDecCustomData: String

A list of at least two values separated by commas (,) or a reference to a range of cells containing these values; decimal values can be used. The range must be one-dimensional (adjoining cells in one row or one column).

Supplies a list of data for cbDecType = cbDecVarTypeCustom [4]