DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Public Property as an Array

  1. #1
    Barry Guest

    Public Property as an Array


    I have a component that searches a DB and returns a result set. The results
    of the search are placed in a Public Property and the the host application
    reads the property and adds the search resutls to a list control. This all
    works great when there is only one item in the results set but when there
    are more than one my list comes up a little short.

    Is there a way to set the property to be an array? I want to feed the record
    set into an array and then pass the array to the application to propogate
    the list box.

    Any help would be greatly appreciated!

    Thanks,
    -Barry

  2. #2
    Colin McGuigan Guest

    Re: Public Property as an Array

    Barry wrote in message <39087008$1@news.devx.com>...
    >
    >I have a component that searches a DB and returns a result set. The

    results
    >of the search are placed in a Public Property and the the host application
    >reads the property and adds the search resutls to a list control. This all
    >works great when there is only one item in the results set but when there
    >are more than one my list comes up a little short.
    >
    >Is there a way to set the property to be an array? I want to feed the

    record
    >set into an array and then pass the array to the application to propogate
    >the list box.
    >
    >Any help would be greatly appreciated!
    >
    >Thanks,
    >-Barry


    Yep. I could swear this topic's been discussed in this forum before. You
    might want to do a search at http://news.devx.com for it. I vaguely
    remember there being some difference between VB 5 and 6 in this regards.
    But, anywhos...

    Public Property Get MyArray() As Long()
    End Property

    Public Property Let MyArray(newMyArray() As Long)
    End Property

    ....does the trick in VB 6. If this doesn't work in VB 5, you can just use
    it as a Variant (which can hold an array), as so:

    Public Property Get MyArray() As Variant
    End Property

    Public Property Let MyArray(newMyArray As Variant)
    End Property


    --
    Colin McGuigan




  3. #3
    Mike Culley Guest

    Re: Public Property as an Array


    Barry,

    You could do it like this

    Public Property Get Value(ByVal Index as Long) as long
    Value= MyArray(index)
    end property

    'and this only if required
    public property Let Value(ByVal Index as long,ByVal NewVal as long)
    MyArray(Index)=NewVal
    end property

    Mike

    "Barry" <barry@drake.com> wrote:
    >
    >I have a component that searches a DB and returns a result set. The results
    >of the search are placed in a Public Property and the the host application
    >reads the property and adds the search resutls to a list control. This

    all
    >works great when there is only one item in the results set but when there
    >are more than one my list comes up a little short.
    >
    >Is there a way to set the property to be an array? I want to feed the record
    >set into an array and then pass the array to the application to propogate
    >the list box.
    >
    >Any help would be greatly appreciated!
    >
    >Thanks,
    >-Barry



  4. #4
    Sameer Gupta Guest

    Re: Public Property as an Array


    Hi Barry
    This problem is occuring may be b'coz of two reasons :-

    1) The recordset pointer through which you are adding data to the list-box
    is moving to the last record when you try to read it.
    2) may be ur recordset pointer is not pointing to the next item
    in the loop

    U try to debug the application and print every record which goes to the list-box.

    Good luck
    Sam





    "Barry" <barry@drake.com> wrote:
    >
    >I have a component that searches a DB and returns a result set. The results
    >of the search are placed in a Public Property and the the host application
    >reads the property and adds the search resutls to a list control. This

    all
    >works great when there is only one item in the results set but when there
    >are more than one my list comes up a little short.
    >
    >Is there a way to set the property to be an array? I want to feed the record
    >set into an array and then pass the array to the application to propogate
    >the list box.
    >
    >Any help would be greatly appreciated!
    >
    >Thanks,
    >-Barry



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center