VBA - ArrayList - Get element at index -
i kind of new vba , stuck @ simple task of getting element out of arraylist @ spesified index.
set resultlist = createobject("system.collections.arraylist") resultlist.add element1 resultlist.add element2 resultlist.add element3 resultlist.add element4 return resultlist.get(2) '<-- not working i have checked documentation of arraylist failed find such "get(index)" function: https://msdn.microsoft.com/de-de/library/system.collections.arraylist(v=vs.110).aspx
thanks in advance.
if can legally use return resultlist.item(2) , have working code, you're not using vba vb.net.
in vba function's return value needs assigned using function's identifier:
public function getfoo() string getfoo = "hello" end functionin vb.net function's return value returned using
returnkeyword:public function getfoo() string return "hello" end function
and if you're using vb.net, have absolutely no reason whatsoever use createobject create arraylist.
and if you're using .net 2.0 or greater, have absolutely 0 reason use arraylist anyway.
use generic list(of sometype) , enjoy type safety.
that said, item arraylist's default property, this:
return resultlist(2)
Comments
Post a Comment