One of my own....
-
Protected Overridable Function getActivityMarketValue(ByVal act As IActivityRecord, ByVal brokerRecord As IST4Record) As Double
Call getTradeMarketValue(act, brokerRecord)
End FunctionI stepped through this about 3 times before I worked out why the activity market value kept being set to zero... :doh:
-
Protected Overridable Function getActivityMarketValue(ByVal act As IActivityRecord, ByVal brokerRecord As IST4Record) As Double
Call getTradeMarketValue(act, brokerRecord)
End FunctionI stepped through this about 3 times before I worked out why the activity market value kept being set to zero... :doh:
... Aaaand the reason is... ? :confused:
-
... Aaaand the reason is... ? :confused:
I was calling the function - not returning it...so even though the right market value was calculated, it never left that function.
-
I was calling the function - not returning it...so even though the right market value was calculated, it never left that function.
Brilliant VB language definition... :omg: A function returns a default value if no return value is specified explicitly... :doh:
-
Brilliant VB language definition... :omg: A function returns a default value if no return value is specified explicitly... :doh:
It's not just VB which does that
-
Protected Overridable Function getActivityMarketValue(ByVal act As IActivityRecord, ByVal brokerRecord As IST4Record) As Double
Call getTradeMarketValue(act, brokerRecord)
End FunctionI stepped through this about 3 times before I worked out why the activity market value kept being set to zero... :doh:
The beauty of VB... :-D
Skipper: We'll fix it. Alex: Fix it? How you gonna fix this? Skipper: Grit, spit and a whole lotta duct tape.
-
Protected Overridable Function getActivityMarketValue(ByVal act As IActivityRecord, ByVal brokerRecord As IST4Record) As Double
Call getTradeMarketValue(act, brokerRecord)
End FunctionI stepped through this about 3 times before I worked out why the activity market value kept being set to zero... :doh:
Shouldn't that create a compiler error or at least warning as your function doesn't explicitly return a value?
-
Protected Overridable Function getActivityMarketValue(ByVal act As IActivityRecord, ByVal brokerRecord As IST4Record) As Double
Call getTradeMarketValue(act, brokerRecord)
End FunctionI stepped through this about 3 times before I worked out why the activity market value kept being set to zero... :doh:
At least in C# it tells you when you're supposed to return a value. I don't suppose this would have been caught by turning on VB's "strict" option? Of course, the last time I did that to some VB code I inherited, I got thousands of errors. :doh: Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
-
Shouldn't that create a compiler error or at least warning as your function doesn't explicitly return a value?
It gives you a warning:
BC42353 Function 'getActivityMarketValue' doesn't return a value on all code paths. Are you missing a 'Return' statement?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
At least in C# it tells you when you're supposed to return a value. I don't suppose this would have been caught by turning on VB's "strict" option? Of course, the last time I did that to some VB code I inherited, I got thousands of errors. :doh: Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
I think "Option Strict" would pick that up alright. But I think the same rule applies to coding as parenting - if the child is already 5 years old it is way too late to start getting strict ;-)