Saturday, 15 March 2014

vb.net - VB ByRef does not work -



vb.net - VB ByRef does not work -

hello site nr1 code inspiration, have problem myselve can't fix.

i have module commctrl contains tagcollection in class made reference collection if fill reference items, items added in class, not in commctrl class. don't understand why reference not working.

public module commctrl public tagcollection new list(of tag) private waypointmanager waypointclass public sub buildconfigdata() waypointmanager = new waypointclass() waypointmanager.settaglistreference(tagcollection) ' count items in tagcollection here 0 items phone call waypointmanager.filltags ' count items in tagcollection here still 0 items?? end sub end module public class waypointclass private taglistreference list(of tag) public sub settaglistreference(byref taglist list(of tag)) taglistreference = taglist end sub public function filltags() boolean taglistreference = xmlbuddy.deserialize(reader) ' fill taglist ' count items in taglistreference here 100 items end function end class

a method's parameter byref keyword can take place if parameter appears on left hand side of assignment.

sub modify(byref p integer) p = 1 ' byref param on lhs of assignment end sub dim int = 0 phone call modify(a) console.writeline(a) ' prints 1

vb.net pass-by-reference

No comments:

Post a Comment