Results 1 to 6 of 6

Thread: Object Programming Question (Resolved)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Fort Worth, Texas, USA
    Posts
    264

    Object Programming Question (Resolved)

    Hello,

    I've set up an object, and am trying to nest other objects. However, it seems that it won't work. Can anyone help?

    Example Code (in a .BAS Module):

    Public Type AObj
    Param1 as Integer
    Param2 as Integer
    End Type

    Public Type BObj
    Params as AObj
    End Type

    Public BigObject as BObj

    When using this, I can enter:
    a = BigObject.Params

    The following won't work:
    a = BigObject.Params.Param1
    a = BigObject.Params.Param2

    Any Ideas on how to make this work?
    I'm using VB6-SP5

    Thanks,
    Ken
    Last edited by Ken Whiteman; Oct 24th, 2002 at 05:13 PM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    1-does vb6 support oop & Inheritence ?I don't think so
    2-Don't you have to use class to build your code ?(I think you have to) ?
    If this is wrong plz let me know .
    Pirate

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Fort Worth, Texas, USA
    Posts
    264
    I Know VB6 doesn't support inheritance, but I'm not sure about oop.

    I'm not sure why I'de need to use Class Builder (I'm not very good with class).

    Ken

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    Does this work?
    VB Code:
    1. a = BigObject.Params
    2.  
    3. b = a.Param1
    4. b = b.Param2

    I'm pretty sure this "nesting" of types works in VB6, I've done it before......
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Lively Member
    Join Date
    Oct 2002
    Location
    Los Angeles, CA
    Posts
    73
    a = BigObject.Params.Param1

    It would not work because of type mismatch

    a is a type of BObj and BigObject.Params.Param1 is an integer.

    It shuld be
    a.Param1 = BigObject.Params.Param1

    In general you are confusing UDT and objects that are not the same thing

    You can use inheritance technigue in VB. Read about keuword Implements

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Fort Worth, Texas, USA
    Posts
    264

    Resolved!

    Split,

    You are correct, I am working with UDT's.



    When you "Nest" UDT's, all subordinates of each of the UDT's must be fully functional and correct, or else none of the UDT will work. Also, each subordinate must have at least 1 item.

    Thanks all,

    Ken

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