Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18013
Number of posts: 55386

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
vb "this" object Posted by rickrat on 27 Oct 2005 at 11:11 AM
hey all,
I am writing a program that uses an abstract class by using the implements keyword from vb. I have two classes inheriting from a master class. In the master class, i have a public variable declared as a class.

Public x As Class5

When i implement the master class (Class1) into the inheritable classes (Class2 and Class3) i am allowed to (in a way) overload the variable x by saying:

private property Set Class1_x(byval RHS as Class5)
...

so, outside of my class, in a commandbutton click event or something, i want to say the following:

Dim blah as Class1
Set blah = different_class


anyway, you get the picture... the problem is coming from the private property, i know what i'm passing in, in this case, it's different_class being passed in as RHS, but i need to set something equal to RHS.... in c++ i could simply say this = RHS, in java, i think i could say something like super = RHS, is there some way to tell what object is being passed in????

Eric
Report
Re: vb "this" object Posted by infidel on 28 Oct 2005 at 6:56 AM
: hey all,
: I am writing a program that uses an abstract class by using the implements keyword from vb. I have two classes inheriting from a master class. In the master class, i have a public variable declared as a class.
:
: Public x As Class5
:
: When i implement the master class (Class1) into the inheritable classes (Class2 and Class3) i am allowed to (in a way) overload the variable x by saying:
:
: private property Set Class1_x(byval RHS as Class5)
: ...
:
: so, outside of my class, in a commandbutton click event or something, i want to say the following:
:
: Dim blah as Class1
: Set blah = different_class
:
:
: anyway, you get the picture... the problem is coming from the private property, i know what i'm passing in, in this case, it's different_class being passed in as RHS, but i need to set something equal to RHS.... in c++ i could simply say this = RHS, in java, i think i could say something like super = RHS, is there some way to tell what object is being passed in????

Well, a couple of things. In VB6 you're not dealing with inheritance. The Implements keyword is a polymorphic feature, like Java's Interfaces. So inside a VB class there's no such thing as "super". There is a "Me" object that lets you refer to a class's properties and methods from within that class, which is similar to Java/C++ "this".

Ok, so your class has a property and you pass some instance of something to it and the code sees it as something named "RHS". You can do anything you want to with RHS except set it to the instance of the class that received it.


infidel

$ select * from users where clue > 0
no rows returned





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.