Hi Anil,
Let me see if I understand you correctly - you're asking how top create a
method that can be used across multiple forms?
If the forms are all similar, I'd use visual inheritence. For this example,
I've created three forms - one parent form (ParentForm.vb) and two inheriting
child forms (ChildForm1.vb and ChildForm2.vb).
The parent form has the data save method (SaveData). This can be called from
any of the three forms, but for ease of use, I've created a button on the
parent form that calls the code. This would then be inherited by the children
forms.
Here's the code:
ParentForm.vb
-----------------
Public Class ParentForm
Inherits System.Windows.Forms.Form
' Removed Windows generated code for brevity
Protected Sub SaveData()
'Save your data here
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
SaveData()
End Sub
End Class
ChildForm1.vb:
-----------------
Public Class ChildForm1
Inherits WindowsApplication2.ParentForm
' Removed Windows generated code for brevity
End Class
ChildForm2.vb:
-----------------
Public Class ChildForm2
Inherits WindowsApplication2.ParentForm
' Removed Windows generated code for brevity
End Class
As you can see, there's no code in either of the children forms to do the
save data - that's all inherited from the parent (base) class. If you need
need to call the parent's SaveData method from the children, it's still
possible by using MyBase.SaveData().
Hope this example helps you along your way.
Adam