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.


 '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

See also  How to Avoid Money Transfer Scams  

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist