Hi
I have two distinct classes A & B. I am using class B from within Class A
as follows;
Public Class clsClassA
Friend ClassB As new ClassB
Public Sub New()
ClassB = new ClassB
End Sub
....
End Class
My question is how can I refer to instance of Class A which called Class B,
from within Class B in this scenario?
Thanks
Regards 7 1361
* "John" <jo**@nospam.infovis.co.uk> scripsit: I have two distinct classes A & B. I am using class B from within Class A as follows;
Public Class clsClassA
Friend ClassB As new ClassB
Public Sub New() ClassB = new ClassB End Sub ... End Class
My question is how can I refer to instance of Class A which called Class B, from within Class B in this scenario?
Pass a reference to the calling class.
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
A quick code example? Sorry vb6 background. Not strong on classes.
Thanks
Regards
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c0*************@ID-208219.news.uni-berlin.de... * "John" <jo**@nospam.infovis.co.uk> scripsit: I have two distinct classes A & B. I am using class B from within Class
A as follows;
Public Class clsClassA
Friend ClassB As new ClassB
Public Sub New() ClassB = new ClassB End Sub ... End Class
My question is how can I refer to instance of Class A which called Class
B, from within Class B in this scenario?
Pass a reference to the calling class.
-- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet>
John, Pass a reference to the calling class. A quick code example?
The "easiest" way is to pass ClassA as a parameter to ClassB's constructor,
something like:
Public Class ClassA
Private m_b As ClassB
Public Sub New()
m_b = new ClassB(Me)
End Sub
End Class
Public Class ClassB
Private m_a As ClassA
Public Sub New(ByVal a As ClassA)
m_a = a
End Sub
End Class
Sorry vb6 background. Not strong on classes.
I would recommend Robin A. Reynolds-Haertle's book "OOP with Microsoft
Visual Basic.NET and Microsoft Visual C#.NET" from MS Press, she does a very
good job of explaining the How of OOP in VB.NET. However! she does not
necessarily cover the Why of OOP.
Hope this helps
Jay
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:OT****************@tk2msftngp13.phx.gbl... A quick code example? Sorry vb6 background. Not strong on classes.
Thanks
Regards
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:c0*************@ID-208219.news.uni-berlin.de... * "John" <jo**@nospam.infovis.co.uk> scripsit: I have two distinct classes A & B. I am using class B from within
Class A as follows;
Public Class clsClassA
Friend ClassB As new ClassB
Public Sub New() ClassB = new ClassB End Sub ... End Class
My question is how can I refer to instance of Class A which called
Class B, from within Class B in this scenario?
Pass a reference to the calling class.
-- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet>
Thanks.
'Why' is overrated anyway. :) Geek's point of view.
Regards
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eF**************@TK2MSFTNGP12.phx.gbl... John, Pass a reference to the calling class. A quick code example?
The "easiest" way is to pass ClassA as a parameter to ClassB's
constructor, something like:
Public Class ClassA
Private m_b As ClassB
Public Sub New() m_b = new ClassB(Me) End Sub
End Class
Public Class ClassB
Private m_a As ClassA
Public Sub New(ByVal a As ClassA) m_a = a End Sub
End Class
Sorry vb6 background. Not strong on classes. I would recommend Robin A. Reynolds-Haertle's book "OOP with Microsoft Visual Basic.NET and Microsoft Visual C#.NET" from MS Press, she does a
very good job of explaining the How of OOP in VB.NET. However! she does not necessarily cover the Why of OOP.
Hope this helps Jay
"John" <jo**@nospam.infovis.co.uk> wrote in message news:OT****************@tk2msftngp13.phx.gbl... A quick code example? Sorry vb6 background. Not strong on classes.
Thanks
Regards
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:c0*************@ID-208219.news.uni-berlin.de... * "John" <jo**@nospam.infovis.co.uk> scripsit: > I have two distinct classes A & B. I am using class B from within Class A > as follows; > > Public Class clsClassA > > Friend ClassB As new ClassB > > Public Sub New() > ClassB = new ClassB > End Sub > ... > End Class > > My question is how can I refer to instance of Class A which called Class B, > from within Class B in this scenario?
Pass a reference to the calling class.
-- Herfried K. Wagner [MVP] <http://www.mvps.org/dotnet>
John,
??
Without the "why" why practice OOA, OOD, and OOP?
If the "Why" is overrated, then I don't see that you would bother with
Classes & OOP!
OOA = Object Oriented Analysis
OOD = Object Oriented Design
OOP = Object Oriented Programming
Just a thought
Jay
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:OV*************@TK2MSFTNGP12.phx.gbl... Thanks.
'Why' is overrated anyway. :) Geek's point of view.
Regards
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:eF**************@TK2MSFTNGP12.phx.gbl... John, > Pass a reference to the calling class. A quick code example?
The "easiest" way is to pass ClassA as a parameter to ClassB's constructor, something like:
Public Class ClassA
Private m_b As ClassB
Public Sub New() m_b = new ClassB(Me) End Sub
End Class
Public Class ClassB
Private m_a As ClassA
Public Sub New(ByVal a As ClassA) m_a = a End Sub
End Class
Sorry vb6 background. Not strong on classes. I would recommend Robin A. Reynolds-Haertle's book "OOP with Microsoft Visual Basic.NET and Microsoft Visual C#.NET" from MS Press, she does a very good job of explaining the How of OOP in VB.NET. However! she does not necessarily cover the Why of OOP.
Hope this helps Jay
"John" <jo**@nospam.infovis.co.uk> wrote in message news:OT****************@tk2msftngp13.phx.gbl... A quick code example? Sorry vb6 background. Not strong on classes.
Thanks
Regards
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message news:c0*************@ID-208219.news.uni-berlin.de... > * "John" <jo**@nospam.infovis.co.uk> scripsit: > > I have two distinct classes A & B. I am using class B from within Class A > > as follows; > > > > Public Class clsClassA > > > > Friend ClassB As new ClassB > > > > Public Sub New() > > ClassB = new ClassB > > End Sub > > ... > > End Class > > > > My question is how can I refer to instance of Class A which called Class B, > > from within Class B in this scenario? > > Pass a reference to the calling class. > > -- > Herfried K. Wagner [MVP] > <http://www.mvps.org/dotnet>
OK, what I meant was, I have been to access, vb4,5,6 etc. They do the job
for me too, db apps. So I had been relatively comfortable with them and
probably not that much until now with vb.net even though it is OO. Point
being it slightly gets to one's head if you miss things here and there that
make your job difficult and all the time it is OO. I would rather they put
those drag drop db stuff as soon as pos and I am happy if my db app gets
done, on time, OO or no OO.
Just my thoughts...
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl... John, ??
Without the "why" why practice OOA, OOD, and OOP?
If the "Why" is overrated, then I don't see that you would bother with Classes & OOP!
OOA = Object Oriented Analysis OOD = Object Oriented Design OOP = Object Oriented Programming
Just a thought Jay
"John" <jo**@nospam.infovis.co.uk> wrote in message news:OV*************@TK2MSFTNGP12.phx.gbl... Thanks.
'Why' is overrated anyway. :) Geek's point of view.
Regards
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message news:eF**************@TK2MSFTNGP12.phx.gbl... John, > > Pass a reference to the calling class. > A quick code example?
The "easiest" way is to pass ClassA as a parameter to ClassB's constructor, something like:
Public Class ClassA
Private m_b As ClassB
Public Sub New() m_b = new ClassB(Me) End Sub
End Class
Public Class ClassB
Private m_a As ClassA
Public Sub New(ByVal a As ClassA) m_a = a End Sub
End Class
> Sorry vb6 background. Not strong on classes. I would recommend Robin A. Reynolds-Haertle's book "OOP with Microsoft Visual Basic.NET and Microsoft Visual C#.NET" from MS Press, she does
a very good job of explaining the How of OOP in VB.NET. However! she does not necessarily cover the Why of OOP.
Hope this helps Jay
"John" <jo**@nospam.infovis.co.uk> wrote in message news:OT****************@tk2msftngp13.phx.gbl... > A quick code example? Sorry vb6 background. Not strong on classes. > > Thanks > > Regards > > "Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in
message > news:c0*************@ID-208219.news.uni-berlin.de... > > * "John" <jo**@nospam.infovis.co.uk> scripsit: > > > I have two distinct classes A & B. I am using class B from
within Class > A > > > as follows; > > > > > > Public Class clsClassA > > > > > > Friend ClassB As new ClassB > > > > > > Public Sub New() > > > ClassB = new ClassB > > > End Sub > > > ... > > > End Class > > > > > > My question is how can I refer to instance of Class A which
called Class > B, > > > from within Class B in this scenario? > > > > Pass a reference to the calling class. > > > > -- > > Herfried K. Wagner [MVP] > > <http://www.mvps.org/dotnet> > >
John,
You'll like the new RAD features in Whidbey then. http://msdn.microsoft.com/library/de...ms12182003.asp
Hope this helps
Jay
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:OB**************@TK2MSFTNGP11.phx.gbl... OK, what I meant was, I have been to access, vb4,5,6 etc. They do the job for me too, db apps. So I had been relatively comfortable with them and probably not that much until now with vb.net even though it is OO. Point being it slightly gets to one's head if you miss things here and there
that make your job difficult and all the time it is OO. I would rather they put those drag drop db stuff as soon as pos and I am happy if my db app gets done, on time, OO or no OO.
Just my thoughts...
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl... John, ??
Without the "why" why practice OOA, OOD, and OOP?
If the "Why" is overrated, then I don't see that you would bother with Classes & OOP!
OOA = Object Oriented Analysis OOD = Object Oriented Design OOP = Object Oriented Programming
Just a thought Jay
"John" <jo**@nospam.infovis.co.uk> wrote in message news:OV*************@TK2MSFTNGP12.phx.gbl... Thanks.
'Why' is overrated anyway. :) Geek's point of view.
Regards
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:eF**************@TK2MSFTNGP12.phx.gbl... > John, > > > Pass a reference to the calling class. > > A quick code example? > > The "easiest" way is to pass ClassA as a parameter to ClassB's constructor, > something like: > > Public Class ClassA > > Private m_b As ClassB > > Public Sub New() > m_b = new ClassB(Me) > End Sub > > End Class > > Public Class ClassB > > Private m_a As ClassA > > Public Sub New(ByVal a As ClassA) > m_a = a > End Sub > > End Class > > > Sorry vb6 background. Not strong on classes. > I would recommend Robin A. Reynolds-Haertle's book "OOP with
Microsoft > Visual Basic.NET and Microsoft Visual C#.NET" from MS Press, she
does a very > good job of explaining the How of OOP in VB.NET. However! she does
not > necessarily cover the Why of OOP. > > Hope this helps > Jay > > "John" <jo**@nospam.infovis.co.uk> wrote in message > news:OT****************@tk2msftngp13.phx.gbl... > > A quick code example? Sorry vb6 background. Not strong on classes. > > > > Thanks > > > > Regards > > > > "Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in
message > > news:c0*************@ID-208219.news.uni-berlin.de... > > > * "John" <jo**@nospam.infovis.co.uk> scripsit: > > > > I have two distinct classes A & B. I am using class B from within > Class > > A > > > > as follows; > > > > > > > > Public Class clsClassA > > > > > > > > Friend ClassB As new ClassB > > > > > > > > Public Sub New() > > > > ClassB = new ClassB > > > > End Sub > > > > ... > > > > End Class > > > > > > > > My question is how can I refer to instance of Class A which called > Class > > B, > > > > from within Class B in this scenario? > > > > > > Pass a reference to the calling class. > > > > > > -- > > > Herfried K. Wagner [MVP] > > > <http://www.mvps.org/dotnet> > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Milind |
last post by:
Hi,
I was trying to implement a composition relation, somthing of the
following type:
class A
{
public:
class B
{
|
by: Macka |
last post by:
A few pieces of information first:
* I have a class called Folder which represents a row of data in a
database table. The data access side of things is not an issue.
* The table has a parent...
|
by: Torrance S. |
last post by:
Hi,
I have a class in an assembly that references a value in web.config
like this:
<appSettings>
<add key="mykey" value="myvalue"/>
</appSettings>
string temp =...
|
by: PromisedOyster |
last post by:
Hi
I have a situation where I want to use circular referencing. I have cut
down the example for demonstration purposes.
Say we have one executable (main.exe) and two DLLS (A1.dll and A2.dll)....
|
by: Mikey_Doc |
last post by:
Hi
We are running cms 2002, Framework 1.0 with Visual studio 2002. We
have just upgraded to Framework 1.1 and visual studio 2003.
All of our database connection strings are stored within the...
|
by: Mantorok |
last post by:
Hi all
I have a web-service that references another project (the component) that
actually carries out the work, the web-service is simply acting as the public
interface.
The web-service on...
|
by: Tim F |
last post by:
Problem: I'm receiving the error "File or assembly name XXXXX or one of its
dependencies, was not found." when trying to execute code in an assmebly that
has both a strong-name and has been...
|
by: Ugo Van Noorbeeck |
last post by:
Hi all,
I try to reference several pages from a class (ideally located in a class
library). But no namespace is available to do this.
Does anybody have an idea how to do this?
Thanks for...
|
by: Tom |
last post by:
My unsigned DLL works in my project that references it as long as I
set Copy Local = true.
Now I have signed the DLL with the sn.exe generated keys but have not
yet moved the DLL into the GAC.
...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |