J
JackRazz
Hi everyone,
I'm trying to figure out how to pass enumerations to subroutines by reference so that
I can return a changed enumerated value. For example, I have a UpdateProperty
function that could take all integer enumerations, set it, and return it's updated
value.
When I do something like: isDirty =
ControlSettingTemplates.UpdateProperty(CType(Me.WindowState, Integer),
CType(aControl.WindowState, Integer))
Friend Shared Function UpdateProperty(ByRef aControlSettingInteger As Integer,
ByRef aControlInteger As Integer) As Boolean
If aControlSettingInteger <> aControlInteger Then
aControlSettingInteger = aControlInteger
Return True
End If
End Function
But it won't work. The first one where I cast it to an integer properly passes the
value to the function, but doesn't return it. I'm pretty sure its because I casted,
which changed it from a ref to a value.
I could potentially have hundreds of different enumerations to pass,so I want to be
able to call the approperiate overloaded UpdateProperty(byte, integer, long, etc).
Is there a way I can cast the enumerated parameter so its still ByRef or create an
UpdateProperty that would accept all enumerated types and then handle based on its
underlying type? I hope what I want makes since.
Thanks - JackRazz
I'm trying to figure out how to pass enumerations to subroutines by reference so that
I can return a changed enumerated value. For example, I have a UpdateProperty
function that could take all integer enumerations, set it, and return it's updated
value.
When I do something like: isDirty =
ControlSettingTemplates.UpdateProperty(CType(Me.WindowState, Integer),
CType(aControl.WindowState, Integer))
Friend Shared Function UpdateProperty(ByRef aControlSettingInteger As Integer,
ByRef aControlInteger As Integer) As Boolean
If aControlSettingInteger <> aControlInteger Then
aControlSettingInteger = aControlInteger
Return True
End If
End Function
But it won't work. The first one where I cast it to an integer properly passes the
value to the function, but doesn't return it. I'm pretty sure its because I casted,
which changed it from a ref to a value.
I could potentially have hundreds of different enumerations to pass,so I want to be
able to call the approperiate overloaded UpdateProperty(byte, integer, long, etc).
Is there a way I can cast the enumerated parameter so its still ByRef or create an
UpdateProperty that would accept all enumerated types and then handle based on its
underlying type? I hope what I want makes since.
Thanks - JackRazz