devxlogo

Passing a UDT(User-Defined Type) Between Forms

Passing a UDT(User-Defined Type) Between Forms

There is a very simple way to get around the compile error when passing UDT (user-defined type) in procedure between forms. Just declare the procedure as Friend instead of Public.
Example:

 'Module: Module1Option ExplicitPublic Type Color    Red As Byte    Green As Byte    Blue As ByteEnd Type'Form: Form1Option ExplicitPrivate Sub Command1_Click()Dim vColor As Color   With vColor      .Red = &HFF      .Green = &HC0      .Blue = &H00   End With   Form2.Show   Form2.mEntryPoint vColorEnd Sub'Form: Form2Option ExplicitFriend Sub mEntryPoint(vColor As Color)   With vColor      Text1.Text = CStr(.Red)      Text2.Text = CStr(.Green)      Text3.Text = CStr(.Blue)   End WithEnd Sub

size=>

devx-admin

Share the Post: