VB.NET For Each Loop exits after one iteration -
i have each loop iterating 1 element. begins 6th element out of 32 in test, , happens 1 comp.includeme evaluates true. after outer if statement executed, begins 2nd iteration exits loop , returns after comp.includeme evaluated false. no errors or warnings present, , have verified there elements in components object. can explain doing wrong, , why syntax doesn't work?
public class bom public property components new list(of component) public function totalarea(byval adjusted boolean) double dim total double = 0 each comp component in components if comp.includeme = true if adjusted total += comp.getadjustedsize() * comp.quantity else total += comp.area * comp.quantity end if end if next return total end function public sub add(byval comp component) components.add(comp) end sub end class public class component public property quantity integer public property area double public property includeme boolean ... end class ' object construction dim bomlist new bom bomlist.add(comp)
after digging little deeper, seems foreach statement recognizing first if statement , pulls values if true. realized had had 1 component includeme boolean set true. after set other components true well, observed each iterates number of times number of components includeme = true
Comments
Post a Comment