Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

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?
0
ocsurf
Asked:
ocsurf
  • 2
1 Solution
 
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now