Class / Class within Class/ & Array problems-VBForums
Results 1 to 4 of 4

Thread: Class / Class within Class/ & Array problems

  1. #1

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,420

    Question Class / Class within Class/ & Array problems

    Hello,

    I seem to be having some trouble with Classes & arrays etc...

    So my structure is as follows:

    Code Code:
    1. Class1
    2. --Method
    3. --Method
    4. --Class2.Property
    5. --Class2.Property
    6. --Class2.Class3.Property
    7. --Class2.Class3.Property

    But Assuming Class2 needs to be an Array(0 to 10) thats when we have problems assigning things!!

    Dim test as Class2
    Set test = new class2

    test = myFunction(myString)


    where myFunction is:

    myFunction(test as string) as Class2
    dim dummyObg AS CLASS2
    set dummyOBg as new class2

    redim dummyobj(0 to 10)
    'code
    'code

    myFunction = dummyobj

    end Function


    Do i have to copy each array separately?
    i.e array(0) = testarray(0)
    array(1) = testarray(1)
    etc.. etc..

    Can't you just do: array = testarray ?
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    17,865

    Re: Class / Class within Class/ & Array problems

    How can Class2 be an array? It's a Class.

    Skinny this down to a very simple example and maybe we'll be able to see where you have gone wrong.

    It would not hurt a bit to STOP. Then go read the manual on Programming with Objects which you can also find in your MSDN CDs.

  3. #3

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,420

    Re: Class / Class within Class/ & Array problems

    The above was off of my head, rather than copy/paste from the actual project


    Actually I need a break to get my head around!!

    You right! How can a class be a array!!
    I need an object referencing the class and that to be an array

    Im basically trying to strip things down, rather than have many objects etc...

    I need: i.e Class2 being an array would be nice
    Class1.Class2(3).Method.Class3.Value
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,072

    Re: Class / Class within Class/ & Array problems

    Do i have to copy each array separately?
    i.e array(0) = testarray(0)
    array(1) = testarray(1)
    etc.. etc..

    Can't you just do: array = testarray ?


    All you have to do is to give it a try. Then you will see what works and what doesn't work.


    A class cannot be an array but you can have an array of classes.

    Class1.Class2(3).Method.Class3.Value

    Looks like something I saw in a Java or C/C++ program.

    Class1 creates instances of Class2 and is refering to the 3rd instance. Is that what you are intending it to be?

    Class2 has a method called Method (in your example)

    Method has an instance of Class3 and Class3 has a property called Value


    So, I guess you have this:

    Class1.Class2(3).Method.Class3.Value

    Is this what your intentios are?


    I don't know if that will work or not.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.