Assignment operator not working

Jeff White 1 Reputation point
2022-04-01T18:13:52.117+00:00

I have a property within a class (FlowType) that is used together with other properties to check whether the combination of values is valid. If the combination of values is valid, then the property value is set. Otherwise the property is left as is. Code is as follows:

Private mUnit As Integer = 0
Public Property Unit As Integer
Get
Return mUnit
End Get
Set (value As Integer)
If ValidFlow(value, mFlow, mFlowMW) Then
mUnit = value
End If
End Set
End Property

I have an instance of FlowType that has a current value of .Unit = 1. I am trying to assign that instance to have a property value of .Unit = 0. The values of mFlow and mFlowMW would be valid with either value of Unit. When I trace through this routine, mUnit =1, value = 0, and ValidFlow returns True. At the assignment statement mUnit = value, value = 0, mUnit = 1. When the assignment statement executes, mUnit remains 1, value remains 0, no error messages are sent. mUnit is not ReadOnly.

What would cause mUnit to refuse to be assigned a new value?

This code has worked properly in other areas of this large program. The program manages information about multiple gas streams in an array of GasStreamType. GasStreamType includes a property that is an array of FlowType. So, the instance where the above failure of the assignment operator happens looks like this:

gsList(iCurrentStream).MixFlow(iFlow).Unit = FunitComboBox.SelectedIndex

Other code that does not involve any array references seems to work consistently. But I can't imagine any reason why the array reference should interfere with the functionality of the property.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,794 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jeff White 1 Reputation point
    2022-04-05T00:57:25.057+00:00

    I did check the value. gsList(iCurrentStream).MixFlow(iFlow).Unit = 1 before the assignment and stayed = 1 after the assignment even though the SelectedIndex value was 0.

    0 comments No comments