Question class decelerarion as array

sathisharavind

New member
Joined
Dec 20, 2011
Messages
1
Programming Experience
5-10
Hai all
I have done developments using class module and property. I have done the deceleration as follows in VB6.

VB6 deceleration

Public BomMatList() As New MaterialList

After this deceleration i use BomMatList as array as follows

BomMatList(I).MatDescription = "New Material"

I can execute this statement on a for loop and change the value of "I" to increase the array size. How can i do the same in Visual Studio 2010.

Thanks in advance.
 
I didn't think they were in VB6 either but arrays definitely not resizable VB.NET. You can use ReDim or ReDim Preserve in VB.NET, as you could in VB6, or Array.Resize to apparently resize an array but, even then, what actually happens is that a new array is created and the contents copied. You definitely cannot implicitly resize an array simply by setting an element by index. If you want a data structure that will resize dynamically then don't use an array. Use a generic List, e.g. a List(Of String), and call its Add method to make the collection grow dynamically.
 
If I find myself needing to use an array (with the exception when using the split function) I choose a standalone recordset (VB6) or DataTable (.Net). Sorry for not answering your question, but standalone recordsets / DataTables are much more powerful.
 
If I find myself needing to use an array (with the exception when using the split function) I choose a standalone recordset (VB6) or DataTable (.Net). Sorry for not answering your question, but standalone recordsets / DataTables are much more powerful.
The fact that something is more powerful is not a reason to use it in situations that don't require that power. If all you need is an array then you should use an array. Use a DataTable only in situations where a DataTable is warranted, which usually, although not always, means when working database data.
 
Back
Top