ID: 180
Viewed: 2998
Added: Apr 29, 2002
Version:
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo
Thank you for your vote. Please wait...
It appears you already voted for this snippet
It appears your vote value was empty
The trick to this tip is to remember that a variant can hold any type of data, including an array. Just define the property as a variant and use it as an array.
The following code is in a class called CArray
Highlight all by clicking in box
<!---Declaration--->
Private m_MyArray As Variant
Public Property Get MyArray() As Variant
MyArray = m_MyArray
End Property
Public Property Let MyArray(a As Variant)
m_MyArray = a
End Property
'You can then use these properties in several different ways, as 'illustrated by the following code from a form
Private m_Array As CArray
Private mArr(3) As String
Private Sub Form_Load()
Set m_Array = New CArray
mArr(1) = "One"
mArr(2) = "Two"
mArr(3) = "Three"
m_Array.MyArray = mArr()
'OR
'm_Array.MyArray = Array("One", "Two", "Three")
End Sub
Highlight All
<!---Code--->
Private Sub Form_Unload(Cancel As Integer)
Dim i As Integer
For i = 1 To UBound(m_Array.MyArray)
MsgBox m_Array.MyArray(i)
Next
End Sub
;
No Comments to show
Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.
Adding your comment. Please wait...
Thanks for adding your comment!. After further review it will be added.
There was a problem adding your comment. Please try again.
Please complete all the fields in the form before sending.