Referencing Subs / Controls on an MDI Child Form Instance

CodyB

Active member
Joined
Jul 23, 2007
Messages
26
Programming Experience
3-5
I have a form I use in 3 different MDI projects, so I created a DLL. Then I created an instance of the form on the ParentMDI form as follows.

VB.NET:
Public Class mdiWoodModeCNC
    Public frmToolChanger As New ATC.frmToolChanger

I use the following code to show the form.

VB.NET:
        CallPage(frmToolChanger)

VB.NET:
    Public Sub CallPage(ByVal CallForm As Object)
        CallForm.MdiParent = Me
        CallForm.WindowState = FormWindowState.Maximized
        CallForm.Show()
        CallForm.BringToFront()
    End Sub

Before I created the DLL I had other forms referencing the Public Subs on frmToolChanger as follows.

VB.NET:
                Dim RB1 As Int16 = frmToolChanger.IOVariables("RB1")
                Dim RB2 As Int16 = frmToolChanger.IOVariables("RB2")
                Dim RB3 As Int16 = frmToolChanger.IOVariables("RB3")

Now frmToolChanger isn't publicly available anymore. So I have to further qualify the call to the sub as follows.

VB.NET:
                Dim RB1 As Int16 = mdiWoodModeCNC.frmToolChanger.IOVariables("RB1")
                Dim RB2 As Int16 = mdiWoodModeCNC.frmToolChanger.IOVariables("RB2")
                Dim RB3 As Int16 = mdiWoodModeCNC.frmToolChanger.IOVariables("RB3")

I've tried creating the frmToolChanger instance as "Public" and "Shared", but it's not available to the other child forms without referencing the ParentMDI. Is there a way to make it available without the additional reference?
 

Latest posts

Back
Top