473,796 Members | 2,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing arrays between classes

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
Nov 21 '05 #1
7 1834
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/de...yreference.asp

HTH

Mona

"Rik" <ri********@yah oo.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
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

Nov 21 '05 #2
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
Nov 21 '05 #3
Rik
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.


"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uk******** *****@TK2MSFTNG P09.phx.gbl...
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

Nov 21 '05 #4
Rik
I finally Solved it.
Mona Thanks your Tips Works.
Cor, Thanks for your HELP too.

Kind Regards,
Rik

"Rik" <ri********@yah oo.com> wrote in message
news:uk******** ******@tk2msftn gp13.phx.gbl...
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.


"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uk******** *****@TK2MSFTNG P09.phx.gbl...
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


Nov 21 '05 #5
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
Nov 21 '05 #6
Rik
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

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
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

Nov 21 '05 #7
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
Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

58
10186
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of code... TCHAR myArray; DoStuff(myArray);
19
1760
by: Method Man | last post by:
I understand that arrays and structs can't be passed by value into and out of functions since they can be arbitrarily big. My question is: Why are types allowed to be passed by value? Couldn't my types be arbitraily big as well?
9
4813
by: justanotherguy63 | last post by:
Hi, I am designing an application where to preserve the hierachy and for code substitability, I need to pass an array of derived class object in place of an array of base class object. Since I am using vector class(STL), the compiler does not allow me to do this. I do realize there is a pitfall in this approach(size of arrays not matching etc), but I wonder how to get around this problem. I have a class hierachy with abstract base...
8
4117
by: kalinga1234 | last post by:
there is a problem regarding passing array of characters to another function(without using structures,pointer etc,).can anybody help me to solve the problem.
1
3442
by: Kurt Richardson | last post by:
Hi all Sorry to bother you with what is probably a really trivial question for you C++ experts. My programming skill are pretty amateur, but I'm pretty good at VB.NET. However, I'm wanting to realise some of the speed benefits of writing some of my routines in C++ and accessing them from my VB software. I have managed to do this with a few simple routines in
1
1523
by: Steve Baer | last post by:
I'm wrapping some unmanaged C++ classes with managed versions for use in the ..NET world. Everything is going great except I can't figure out a good method for passing simple data type arrays into unmanaged classes. Say I have a function void UnManagedClass::FillOutArray(int size, int* data); where data is an array of unmanaged ints and size gives the size of the array. I would like to wrap the function like so
3
3796
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes a variant containing an array, and interop expects a parameter of type object if you are passing a variant (you are expected to cast it to the correct type in your code). I'd like to find a way of passing arrays so that you don't need to change...
17
3686
by: mr.resistor | last post by:
hey i am having a few problems calling a C DLL from C#. i am using a simple function that takes an array of floats and an integer as an input, but i cannot seem to get it to work. when i try to compile i get the following error: Attempted to read or write protected memory the C function should not be manipulating the input arra, only reading
17
7256
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need to show the array data to the end user. Can I do that? How?
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9533
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10239
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9057
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6796
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.