C
Clif McIrvin
Passing a function argument by value is not doing what I expected
it to:
I expect
Me.JobID = "ABC" '(simulate user input)
Me.JobID = EnterInit(Me.JobID)
to leave JobID with the value of "ABC", but it returns as Null.
Private Function EnterInit(ByVal vValue As Variant) As Variant
rem v = vValue
Me.ContractorFind = Null
Me.JobID = Null
Me.JobIDPart = Null
Me.JobName = Null
Me.JobNamePart = Null
ReadyToFind = True
eiReturn:
EnterInit = vValue 'return parameter to caller
rem EnterInit = v 'return parameter to caller
End Function
By single-stepping through the function with the locals window open
I observed that vValue changed from "ABC" to Null when the
Me.JobID = Null statement was executed -- which I would expect
if passing by reference.
My soulution was to add the two lines of code I have shown as 'rem'.
Am I missing something here?
it to:
I expect
Me.JobID = "ABC" '(simulate user input)
Me.JobID = EnterInit(Me.JobID)
to leave JobID with the value of "ABC", but it returns as Null.
Private Function EnterInit(ByVal vValue As Variant) As Variant
rem v = vValue
Me.ContractorFind = Null
Me.JobID = Null
Me.JobIDPart = Null
Me.JobName = Null
Me.JobNamePart = Null
ReadyToFind = True
eiReturn:
EnterInit = vValue 'return parameter to caller
rem EnterInit = v 'return parameter to caller
End Function
By single-stepping through the function with the locals window open
I observed that vValue changed from "ABC" to Null when the
Me.JobID = Null statement was executed -- which I would expect
if passing by reference.
My soulution was to add the two lines of code I have shown as 'rem'.
Am I missing something here?