Question Calling function from another form

ashley.s

New member
Joined
Nov 17, 2011
Messages
3
Programming Experience
Beginner
Hi All,
I have defined a function on one form. I have to call that function again on another form. Is there any way I can do it without redefining the function again and again?
 
A form is a class so the same principles apply to that as with any other class; the member must be public or otherwise accessible within the caller scope, an instance member requires an object reference to be called, and a shared member must be called by only qualifying the type, for example reference.InstanceMethod() or ClassName.SharedMethod()
A programming element exist in VB called Module, within that all members are shared and are also type promoted, so calling a method from that can be done globally without qualifying type, for example ModuleMethod()
 
A general ruled that i have used, is to determine if the exact same method is needed from various places within the application. If so, then the sub or function should be declared as Public and place in a Public Class or Module. You may also define a public function or sub within a form and call it from other forms (FrmMain.MyFunction).
 
Back
Top