you could make the property a variant, they can hold string arrays.
Printable View
you could make the property a variant, they can hold string arrays.
You can create a public property in the form itself.
VB Code:
Option Explicit Private m_arrMyProperty As Variant Public Property Get MyProperty() As Variant MyProperty = m_arrMyProperty End Property Public Property Let MyProperty(ByVal p_arrNewValue As Variant) m_arrMyProperty = p_arrNewValue End Property Private Sub Command1_Click() Dim arr(1) As String arr(0) = "AAA" arr(1) = "BBB" MyProperty = arr End Sub
Alternatively, instead of using nasty variants :p:rolleyes:, just return a dynamic string array...i.e.VB Code:
'Coded by [Digital-X-Treme]... 'In a class, called CStringObj.cls Option Explicit Private m_strAr() As String Private Sub Class_Initialize() Dim i As Integer ReDim m_strAr(10) For i = 0 To 10 m_strAr(i) = i Next i End Sub Public Property Get My_String_Array() As String() My_String_Array = m_strAr() End Property 'In a form... Option Explicit Private Sub Form_Load() Dim i As Integer Dim x As New CStringObj Dim mStrAr() As String mStrAr() = x.My_String_Array For i = 0 To UBound(mStrAr()) Debug.Print mStrAr(i) Next i End Sub
Hope this helps :)
Laterz
Apologies, that code only included a property Get... Here's the complete code.VB Code:
'Coded by [Digital-X-Treme]... 'In a class, called CStringObj.cls Option Explicit Private m_strAr() As String Private Sub Class_Initialize() Dim i As Integer ReDim m_strAr(10) For i = 0 To 10 m_strAr(i) = i Next i End Sub Public Property Get MY_String_Array() As String() MY_String_Array = m_strAr() End Property 'As we have to pass ByRef, copy the argument, element by element, into the private array. Public Property Let MY_String_Array(ByRef strAr() As String) Dim i As Integer ReDim m_strAr(UBound(strAr())) For i = 0 To UBound(strAr()) m_strAr(i) = strAr(i) Next i End Property 'In a form... Option Explicit Private Sub Form_Load() Dim i As Integer Dim x As New CStringObj Dim mStrAr() As String mStrAr() = x.MY_String_Array For i = 0 To UBound(mStrAr()) Debug.Print mStrAr(i) Next i mStrAr(5) = 0 x.MY_String_Array = mStrAr For i = 0 To UBound(mStrAr()) Debug.Print mStrAr(i) Next i End Sub
Hope this helps :)
Laterz