HELP: Can a Property Let refer to a Collection?!?! 
Author Message
 HELP: Can a Property Let refer to a Collection?!?!

Can you create a property in a customized control in which the
property's Property Let refers to a *collection*???? If so, what is the
proper syntax to use in the Declaration section and Property Let section
of the customized control?

Also, once you establish this collection property in the control, what
syntax would you use to place a collection into that property; if, for
example, you had created a collection in some form code that you now
wanted to place into the customized control?

Sorry to be so basic, but I can't seem to make this work... and it feels
as though I've tried every available variation!  Can someone please lend
a hand?  Thanks in advance.



Thu, 19 Apr 2001 03:00:00 GMT  
 HELP: Can a Property Let refer to a Collection?!?!

Quote:

>Can you create a property in a customized control in which the
>property's Property Let refers to a *collection*???? If so, what is the
>proper syntax to use in the Declaration section and Property Let section
>of the customized control?

If I follow this correctly, you'd probably have more luck with Property Set


Thu, 19 Apr 2001 03:00:00 GMT  
 HELP: Can a Property Let refer to a Collection?!?!
It can it this respect:

<Public Class = MyClass1>

Dim TBX As Collection

Public Property Let AddItems(vNewValue)
    Set TBX = vNewValue
End Property

Public Sub Jumble()
Dim i, max, r1&, r2&, tmp$

Randomize      
max = TBX.Count - 1
For i = 0 To 10
    r1 = (Rnd * max) + 1
    r2 = (Rnd * max) + 1
    tmp = TBX(r1).Text
    TBX(r1).Text = TBX(r2).Text
    TBX(r2).Text = tmp
Next i
End Sub

Private Sub Class_Terminate()
Set TBX = Nothing
End Sub

<Public Form1 = Form1>

Dim TheControl As MyClass1

Private Sub Command1_Click()
    TheControl.Jumble
End Sub

Private Sub Form_Load()
Dim colTest As New Collection
    Set TheControl = New MyClass1
    colTest.Add Text1
    colTest.Add Text2
    colTest.Add Text3
    TheControl.AddItems = colTest
    Set colTest = Nothing
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set TheControl = Nothing
End Sub

There are other ways to do it, its surprizing you didn't find
any of them.  

LFS



Thu, 19 Apr 2001 03:00:00 GMT  
 HELP: Can a Property Let refer to a Collection?!?!
: Can you create a property in a customized control in which the
: property's Property Let refers to a *collection*???? If so, what is the
: proper syntax to use in the Declaration section and Property Let section
: of the customized control?

A Collection is an object. As with any object type, you need a Property
Set, not a Property Let.



Fri, 20 Apr 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Help: Refer properties by variable

2. property get / property let

3. Property Let, Property Get

4. Property Let vs. Property Set

5. Help : Optional variables in Property Let

6. Cant refer to control array item in the controls collection

7. Name of Format Property in the Properties collection

8. Changing properties of a Collection with a change event :/ <--- pls help

9. Changing properties of a Collection with a change event :/ <--- pls help

10. Help: Using InvokeMethod to Set property of object in a collection

11. Help: Does a control have a properties collection?

12. Help: Does a control have a properties collection?

 

 
Powered by phpBB® Forum Software