Passing arrays between classes

  • Thread starter Thread starter Rik
  • Start date Start date
R

Rik

Hi,

I have an Multithreaded application in VB.NET.
I inherited a Sub Class and which define an Array variable of string in that
Sub
Class.

Now I want to Carry that Sub Class Array back to the Calling Class??
without using Function Return.
Can any one Help me in this regard.


Thanks in Advance for Help

Rik
 
Hello Rik,

You can pass the array using the ByRef keyword.If you pass a variable
argument by reference
using the ByRef keyword, the procedure can modify the variable itself or in
this case, the array.
So, any changes that are made in the any class will be permanent and would
be reflected in the calling class.

You can refer to following details for more details:

[Argument Passing ByRef]
http://msdn.microsoft.com/library/d...bcn7/html/vaconargumentpassingbyreference.asp

HTH

Mona
 
Rik,

I am curious why don't you want to use the return, can you tell us that, can
be an interesting reason, I never saw one for that?

(Although I know one when I don't use a function however a sub, but that is
than a little bit more complicated in a multithreading operation and loose
than probably all the sense for that multithreading operation).

Cor
 
Mona,

Thanks for your reply. I have to look into this option, although I am aware
of it, but will deeply study it.
Core.
Thanks for your reply too.
Functions only return one value, and that is already being used. where I am
going to send my Array back to the calling......
I don't want to change the whole Program logic due to that.Not a good IDEA,
need your thoughts on it?
I also thought that why not I included that first value part of the array
list, but for that also i need to change all my logic or handling in
Calling.....

I appriciate all your responses.
 
I finally Solved it.
Mona Thanks your Tips Works.
Cor, Thanks for your HELP too.

Kind Regards,
Rik
 
Rik,

When you pass an array, than you don't need to have a return value because
you are passing its reference by value.(Be aware that when you create it new
in the method you have to take a little bit other approach).

Cor
 
Cor,
Sorry for late reply.
I was away.
Just solved it by declaring the local arraylist and passing that arraylist
to another class and getting back the values.

It is working fine yet, but I know ur experience thought are looking beyond
my eyes.
Could you please inform me the danger which I might be facing in future
regarding that technique.

I realy appriciate your help.

Thanks in advance..

Rik
 
Rik,
Could you please inform me the danger which I might be facing in future
regarding that technique.
Sorry Rik, no I cannot do that. For me it is as well, when it is working and
I tested something good, it is working. I cannot see what can be a danger in
future because someting that can happen I don't know.

:-)

Cor
 

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

Back
Top