vb "this" object - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

vb "this" object

rickratrickrat Posts: 55Member
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

Comments

  • infidelinfidel Posts: 2,900Member
    : 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.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]

Sign In or Register to comment.