Results 1 to 7 of 7

Thread: object orented programing?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    Keddie,

    you are right about constructors and destructors but you can get round it to an extent.

    Say you have a class CJones

    You can write an initialisation procedure, Init, say, to initialise the values in the class. (These would be user set values that cannot be set in the Class_Initialize event)

    Code:
    Friend Sub Init(Optional Age As Variant, Optional Height As Variant)
      If Not IsMissing(Age) Then Me.Age = Age
      If Not IsMissing(Height) Then Me.Height = Height
    End Sub
    Then you write a Public Function in a BAS module to instantiate the class.

    Code:
    Public Function New_CJones(Optional Age As Variant, Optional Height As Variant)
      Set New_CJones = New CJones
      New_CJones.Init Age, Height
    End Function
    Then you ask users to write:

    Code:
    Dim j As CJones
    Set j = New_CJones(10, "1.92 Metres")
    You cannot force the user to use the changed code but you can utilise this internally.

    I know all that does not answer the question, but I thought you might be interested.

    Cheers,

    P.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well thats thats almost the way i use, but i like to put them in the higher level object like directX control has it's Directdrawcreate and methods like blablablacreate or createblabla

    Set DDraw = DirectX.DirectDrawCreate("")


    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008
    OK.

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  4. #4
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    Well Guess What. the contstructers for the class are the class its self, on the two drop down boxes in the vb ide, where u select an object and an event ? well goto the .cls file and seelect the class as ur object and initiate or terminate (constructor and deconstructor)

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Not really the same thing, you can't pass any parameters to them
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    You can't pass parameters to the destructor anyway. For the constructor, just use an Init function. BTW - if VB7 has overloaded functions then they'll be on their way to proper OOP
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355
    VB7 will have overloading functions, as well as other OOP stuff like inheritance..finally VB will be a proper OOP language (hopefully)
    buzzwords are the language of fools

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width