Results 1 to 5 of 5

Thread: VB Class structure...

  1. #1

    Thread Starter
    Addicted Member Dim A's Avatar
    Join Date
    Jul 2000
    Posts
    201

    Question

    I'm new to using Classes in VB. I'm fairly familiar with creating classes in C++.

    I'd like any basic information on good class structure that anyone would like to submit.

    I'd also like to add the basic functionality of the operator functions that C++ uses. For instance, I'd like to be able to make statements such as:

    MyClass=MyClass2
    If MyClass<Myclass2 then msgbox lesser

    I'm currently using VB 5.0 if it makes any difference.

    Thanks in advance.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I assure you there's a lot about classes in this forum if you just search for them "classes" "objects" "object oriented" "classmodules" or something like that.

    To operate with your objects like you've demonstrated you need to set a default property for your class which returns the value if you omit it.

    1. Goto Tools in menu
    2. click procedure attributes
    3. click Advanced
    4. select your property in name
    5. select default in procedureID combo
    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
    Addicted Member Dim A's Avatar
    Join Date
    Jul 2000
    Posts
    201
    hmm...

    I'd like to implement classes in such a way that I can do simple assignments...

    A statement like this...
    myClass=myClass2

    Should copy every property from the class myClass2, and place it in myClass similar to the copy constructor or the operator= in c++.

    I'd also like to implement an add operator like
    myDouble=myClass+myClass2
    which will return a double which is computed by adding a couple of properties of the class.

    The add operator looks like it would be easy by assigning a default property, but this would also affect the greater/less comparison, which I want to assign to a different property. The assignment operator seems like it would be even more difficult.

    Thank you for your advice, I will look into the other messages in the forum.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well for copying classes you have to do it manually, or you could set the default procedure a property get that compress all vars inside it and then extract them in the target object in it's property let procedure, the default property. But that's probably just a huge diversion.

    C++ is probably much better when it comes to object orientation. You have to wait for Vb7 for the operation you mentioned

    Also if you just want to have another reference to the object use set statement;
    Code:
    set myclass=myclass2
    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.

  5. #5
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Usually I make My own Copy Mechanism, I have a Clone Property, I have a method SetVariables Declared as a friend that lets you Set the Values of all the Variables in your class, Internal and Public and yuse the Clone Property to return a new Class with the SetVariables method used to set all the Variables In the NewClass.

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