how to initialize array of object with vb.net

G

Guest

I am doing vb.net programming
my problem is
dim myobject() as myclass
i am craeating dynamic array of my object and later i am specifing length of array like
set myobject=new myclass()
redim myobject(TotalLength)
i dont know is that correct sentence i am using cos i am new to vb.net
thanks
 
A

Armin Zingler

Mike said:
I am doing vb.net programming
my problem is
dim myobject() as myclass
i am craeating dynamic array of my object and later i am specifing
length of array like set myobject=new myclass()
redim myobject(TotalLength)
i dont know is that correct sentence i am using cos i am new to
vb.net thanks

I'm not sure what you need.

Use
Redim myobject(upperbound)
to create a new array. Use Redim Preserve to keep the content.

Use
Myobject(index) = new yourclass
to create an new instance of your class and store the reference in the
array.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?TWlrZQ==?= said:
I am doing vb.net programming
my problem is
dim myobject() as myclass
i am craeating dynamic array of my object and later i am specifing length of array like
set myobject=new myclass()
redim myobject(TotalLength)
i dont know is that correct sentence i am using cos i am new to vb.net

'ReDim Preserve MyObject(TotalLenght - 1)'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top