V.B dislikes Object Oriented

.net , vb6 Israel
  • 19 years ago

    Hello,

    How to point to a father class?

    Or in details, I am building a CLASS MOUDLE and facing this problam:
    Assume Class Papa with properties and a sub Class Papas_Child -->



    Class Papa
         .....
         Class Papas_Child
              InitPapa
              ....


         .....
    ......



    Question:

    So Method InitPapa need the pointer to the father what is his name?


    Hope I got my question clear...
    I

  • 19 years ago

    class module

    Code:

    Public strName As String
    Public ObjFather As Class1


    Public Function Init(strInitName As String, Optional ByRef objFatherName As Class1 = Nothing)
       strName = strInitName
       Set ObjFather = objFatherName
    End Function



    Problem Can't override Class_Initialize() you're right on "V.B dislikes Object Oriented"


    form code or somethin else

    Code:

       Dim c1 As New Class1
       Call c1.Init("Father")
       
       Dim c2 As New Class1
       Call c2.Init("Child", c1)
       
       MsgBox "c1.Name = " & c2.strName & " has c2 as father = " & c2.ObjFather.strName


    Hope that is what you wanted



    Xcuse my english

  • 19 years ago

    Hey,


    What I am looking for is in other O.O languages.
    Something like: suprior, or the sort.
    It should be a command or a reserved word.


    Will reprhrase the question:

    Question:

    Inside a method of a sub class I'm trying to change it's father's property.
    How do I point to the father's Class?


    Hope the question is clear.
    Thanks for the tips till now.

  • 19 years ago

    R U lookin a SuperClass kind of Reserved word ?
    If u find such keyw let me know..!!!


    Anyway:
    u want to change the father property of a child class with another father class ?
    (tha's waht u mean by "change it's father's property")
    or
    u want to change a propery of a father class (access a method / change a property of a father class)?


    Both ?
    This I can do...


    i'll send you the code ...
    Answer once again if you please.
    Sorry we (I) are (am) a little confused.



  • 19 years ago

    Class module

    Code:

    Public strName As String
    Public ObjFather As Class1


    Public Function Init(strInitName As String, Optional ByRef objFatherName As Class1 = Nothing)
      strName = strInitName
      Set ObjFather = objFatherName
    End Function


    Public Function FuckTheFather()
    ' this changes father a class property
     If ObjFather Is Nothing Then
       MsgBox "this fucker has no father = ROOT"
       End
     End If
     ObjFather.strName = ObjFather.strName & "it's really fucked up in the ASS !"
    End Function


    Public Function ChangeTheFather(ByRef OtherFather As Class1)
    ' this changes child's papa
       Set ObjFather = OtherFather
    End Function



    form ...

    Code:

    Dim fatherClass As New Class1
    Dim child As New Class1
       
    Private Sub Command1_Click()
       
           Call fatherClass.Init("Father")
           Call child.Init("Child", fatherClass)
           
       MsgBox "fatherClass.Name = " & child.strName & " has child as father = " & child.ObjFather.strName
    End Sub


    Private Sub Command2_Click()
       Call child.FuckTheFather
       MsgBox "Father name is:" & fatherClass.strName
    End Sub


    Private Sub Command3_Click()
       Dim mamaIsABiatch As New Class1
       Call mamaIsABiatch.Init("Other one...")
       Call child.ChangeTheFather(mamaIsABiatch)
       MsgBox "my dad is " & child.ObjFather.strName
    End Sub



    command 1 = init
    command 2 = change fathers property of child (pointing at the father)
    cammand 3 = change the father's child            (---------//-------------)

  • 19 years ago

    All I need to do is to use the Papa’s var name.
    I knew it’s simple but didn’t think it is that simple.


    Silviu – Thanks for your tries – it does look lie you worked on it but it couldn’t have been so difficult.


    Let me explain:


    I am in the child’s class and I need to refer to a var declared in  the father’s class. I was looking for a pop up window to choose it from but couldn’t find it.

    All is needed is to use the actual name.
    V.B. is so far from being Object Oriented.

    Had I known it was that simple.


    I.

  • 19 years ago

    Vb more like Object Based than Object Oriented.
    Do you know if .NET is Object Oriented?
    (in the pure sense not in the "micro"Soft sense..)





Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Memory is like an orgasm. It's a lot better if you don't have to fake it.” - Seymour Cray