ActiveMdiChild - call current class function

I have 4 windows forms : frmMain - set to mdicontainer
frm1,frm2 and frm3 (all 3 have the same function save(), update(), delete(); but the code is different for all)
---CODE---------------------------------
' not full code, just example
Public Class frmMain
      Dim doc As Form
      sub frm1_Click()
        If Not Me.ActiveMdiChild Is Nothing Then
            ActiveMdiChild.Close()
        End If
            doc = New frm1
        doc.MdiParent = Me
        doc.Show()            
      end sub
      sub frm2_Click()
        If Not Me.ActiveMdiChild Is Nothing Then
            ActiveMdiChild.Close()
        End If
            doc = New frm2
        doc.MdiParent = Me
        doc.Show()      
      end sub      
      sub frm3_Click()
        If Not Me.ActiveMdiChild Is Nothing Then
            ActiveMdiChild.Close()
        End If
            doc = New frm3
        doc.MdiParent = Me
        doc.Show()      
      end sub            
      sub save()
            'should call the current class's save function
            doc.save()  <--- Error "save() is not a member of 'System.Windows.Forms.Form'
      end sub            
end class
------------------------------------
Any help?
LVL 1
ocsurfAsked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Makes sure the "save" method on your forms is PUBLIC.

Then try:

    Sub save()
        CallByName(doc, "vave", CallType.Method)
    End Sub
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
oops...

"vave" should be "save"

=)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.