|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Ubound()What is the consensus about using the Ubound function? Should it be avoided
altogether? Is there an arry size where Ubound becomes less efficent? Also, is there a better way to increase the size of an array (preserving its current values) besides using Redim Preserve? Thanks, Mark > What is the consensus about using the Ubound function? Should it be Have you considered the ArrayList? Depending on your needs, it may have advantages. > avoided altogether? Is there an arry size where Ubound becomes less > efficent? > > Also, is there a better way to increase the size of an array > (preserving its current values) besides using Redim Preserve? It does not require a Redim to change the size of the array for one. Jim Wooley http://devauthority.com/blogs/jwooley Mark wrote:
> What is the consensus about using the Ubound function? Should it be avoided I really have no objects to the Ubound function, nor do I know of any> altogether? Is there an arry size where Ubound becomes less efficent? > limits on it's efficeincy. > Also, is there a better way to increase the size of an array (preserving its With a regular array object? Not really. My only advice here is to> current values) besides using Redim Preserve? limit the number of calls to Redim... That means don't call Redim for every element you add - always allocate in chunks. If what you are storing in the array are reference types (classes, not structures) then I would suggest using an arraylist rather then a pure array. An arraylist will grow dynamically (actually, it will essentially do what you have to do manually with a regular array - redim the array that is it's backing store when it needs to grow, but it does it in chunks so you don't have to worry about it). It will most likely give you better performance... If you are using VB.NET 2005, then I would say to use one of the generic list class. It will give you good performance even with value types (structures). If you using 2003 or earlier, then I would consider using a typed array if you are storing value types and managing the array resize your self - I would put it into a class.... I hope my rambling made sense :) -- Tom Shelton [MVP] Good stuff! Thanks a bunch.
Mark Show quoteHide quote "Mark" wrote: > What is the consensus about using the Ubound function? Should it be avoided > altogether? Is there an arry size where Ubound becomes less efficent? > > Also, is there a better way to increase the size of an array (preserving its > current values) besides using Redim Preserve? > > Thanks, > Mark "Mark" <M***@discussions.microsoft.com> schrieb: In addition to the other replies, note that using 'UBound' can make code > What is the consensus about using the Ubound function? Should it be > avoided > altogether? Is there an arry size where Ubound becomes less efficent? shorter and prevent bugs from occuring because it really returns the upper bound opposed to the array object's 'Length' property, which will return the number of items in the array. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
help with converting from VB4.0
knowing when file has been totally transferred urgent: formatting XL cells Reusing VB.NET Form dialogs in VC apps collection question Combobox, Count Entries Looking for a line graph control. stopping current execution App.comfig file in vb.net Help for this pls stored procedure |
|||||||||||||||||||||||