User Defined Type as a public property
Instead of passing the UDT to Form2, just set a public UDT in the BAS module
and Form2 can read from it when it loads.
In the BAS module
Public gudtMan As udtMan
On Form1:
Private Sub Command1_Click()
TheMan.FName = Me.Text1.Text
TheMan.Age = CInt(Me.Text2.Text)
gudtMan = TheMan
Load Form2
End Sub
On Form2:
Private Sub Form_Load()
OtherMan = gudtMan
End Sub
The only place in your particular code that can pass and retrieve the UDT is
the public module where it is declared. The forms are private, even though
they can have public interfaces, they are still private classes.
Quote:
> How can i use user defined types in forms and classes?
> '---User defined type is defined in standart module:
> Public Type udtMan
> FName As String
> Age As Integer
> End Type
> '---Code in Form1:
> Private TheMan As udtMan
> Private Sub Command1_Click()
> TheMan.FName = Me.Text1.Text
> TheMan.Age = CInt(Me.Text2.Text)
> Load Form2
> Form2.Person = TheMan
> End Sub
> '---Code in Form2:
> Private OtherMan As udtMan
> Public Property Let Person(ByRef vData As udtMan)
> OtherMan = vData
> End Property
> '-------------
> I get the following compile error:
> "Only public user defined types defined in public object
> modules can be used as parameters or return types for
> public procedures of class modules or as fields of
> public user defined types"
> Why?
> Thanks
> Dim