Hello,
I'm trying to put sub that's shared between all forms in my app in module so
when I make change I just change it one time.
This sub should execute and then invoke sub defaults() that's different for
each form and is contained within the forms. You'll probably ask why don't I
just put it in the form after the call to module.function, well it's a
handler for one combobox so technically I don't call it.
I made a reference to mainform form and then did
Module sharedFunction
Friend Sub cbo_KeyUp(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs)
'do something
frmMainForm.ActiveMdiChild.Defaults()
End Function
End Module
but I'm getting error message in Visual Studio .Net "C:\Visual
Studio\blabla\functions.vb(267): 'Defaults' is not a member of
'System.Windows.Forms.Form'."
the program executes ok and it does call sub properly but every time I want
to recompile I'm getting build error warning.
btw... sub name (Defaults) is same on each of the forms.
Thanks in advance ... 4 1717
Create a MyDefaults Interface with a Sub Defaults
Add the line Implements MyDefaults to each form's class
Then in your shared cbo_KeyUp sub, use CType(frmMainForm.ActiveMdiChild,
MyDefaults).Defaults()
e.g.
Public Class Form1
Inherits System.Windows.Forms.Form
Implements MyDefaults
Public Sub Defaults() Implements MyDefaults.Defaults
'your custom form specific code here
End Sub
End Class
Public Interface MyDefaults
Sub Defaults()
End Interface
Module sharedFunction
Public frmMainForm As FormMain
Friend Sub cbo_KeyUp(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.KeyEventArgs)
'do something
CType(frmMainForm.ActiveMdiChild, MyDefaults).Defaults()
End Sub
End Module
"excelleinc.com" <vj******@excelleinc.com> wrote in message
news:em****************@TK2MSFTNGP15.phx.gbl... Hello,
I'm trying to put sub that's shared between all forms in my app in module so when I make change I just change it one time.
This sub should execute and then invoke sub defaults() that's different for each form and is contained within the forms. You'll probably ask why don't I just put it in the form after the call to module.function, well it's a handler for one combobox so technically I don't call it.
I made a reference to mainform form and then did Module sharedFunction Friend Sub cbo_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) 'do something frmMainForm.ActiveMdiChild.Defaults() End Function End Module
but I'm getting error message in Visual Studio .Net "C:\Visual Studio\blabla\functions.vb(267): 'Defaults' is not a member of 'System.Windows.Forms.Form'." the program executes ok and it does call sub properly but every time I want to recompile I'm getting build error warning.
btw... sub name (Defaults) is same on each of the forms.
Thanks in advance ...
This is not going to help because I can't call this from module:
CType(frmMainForm.ActiveMdiChild, MyDefaults)
Just like I said, I have different forms calling this sub and in this case
MyDefaults will be bunch of different forms.
Even if I don't involve interfaces I'm able to call
CType(frmMainForm.ActiveMdiChild, MyDefaults).Defaults() from the Module but
as I explained, I'm not able to CType to specific form.
"Jim Hughes" <NO*********@Hotmail.com> wrote in message
news:uy*************@TK2MSFTNGP09.phx.gbl... Create a MyDefaults Interface with a Sub Defaults
Add the line Implements MyDefaults to each form's class
Then in your shared cbo_KeyUp sub, use CType(frmMainForm.ActiveMdiChild, MyDefaults).Defaults()
e.g.
Public Class Form1 Inherits System.Windows.Forms.Form Implements MyDefaults
Public Sub Defaults() Implements MyDefaults.Defaults 'your custom form specific code here End Sub End Class
Public Interface MyDefaults Sub Defaults() End Interface
Module sharedFunction Public frmMainForm As FormMain Friend Sub cbo_KeyUp(ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) 'do something CType(frmMainForm.ActiveMdiChild, MyDefaults).Defaults() End Sub End Module
"excelleinc.com" <vj******@excelleinc.com> wrote in message news:em****************@TK2MSFTNGP15.phx.gbl... Hello,
I'm trying to put sub that's shared between all forms in my app in module so when I make change I just change it one time.
This sub should execute and then invoke sub defaults() that's different for each form and is contained within the forms. You'll probably ask why don't I just put it in the form after the call to module.function, well it's a handler for one combobox so technically I don't call it.
I made a reference to mainform form and then did Module sharedFunction Friend Sub cbo_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) 'do something frmMainForm.ActiveMdiChild.Defaults() End Function End Module
but I'm getting error message in Visual Studio .Net "C:\Visual Studio\blabla\functions.vb(267): 'Defaults' is not a member of 'System.Windows.Forms.Form'." the program executes ok and it does call sub properly but every time I want to recompile I'm getting build error warning.
btw... sub name (Defaults) is same on each of the forms.
Thanks in advance ...
You are not casting to a specifc form, you are casting each form that
implements the interface to an object that implements that interface. You
could even test each form to see see if it implements that interface using
If frmMainForm.ActiveMdiChild Is TypeOf MyDefault Then.
All of the forms will implement that interface and therefore have a Defaults
sub.
MyDefaults is the name of the Interface you define, I just used that one as
an example.
If you don't believe me, do a proof of concept test of this pattern.
"excelleinc.com" <vj******@excelleinc.com> wrote in message
news:ex*************@TK2MSFTNGP10.phx.gbl... This is not going to help because I can't call this from module:
CType(frmMainForm.ActiveMdiChild, MyDefaults)
Just like I said, I have different forms calling this sub and in this case MyDefaults will be bunch of different forms.
Even if I don't involve interfaces I'm able to call CType(frmMainForm.ActiveMdiChild, MyDefaults).Defaults() from the Module but as I explained, I'm not able to CType to specific form. "Jim Hughes" <NO*********@Hotmail.com> wrote in message news:uy*************@TK2MSFTNGP09.phx.gbl... Create a MyDefaults Interface with a Sub Defaults
Add the line Implements MyDefaults to each form's class
Then in your shared cbo_KeyUp sub, use CType(frmMainForm.ActiveMdiChild, MyDefaults).Defaults()
e.g.
Public Class Form1 Inherits System.Windows.Forms.Form Implements MyDefaults
Public Sub Defaults() Implements MyDefaults.Defaults 'your custom form specific code here End Sub End Class
Public Interface MyDefaults Sub Defaults() End Interface
Module sharedFunction Public frmMainForm As FormMain Friend Sub cbo_KeyUp(ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) 'do something CType(frmMainForm.ActiveMdiChild, MyDefaults).Defaults() End Sub End Module
"excelleinc.com" <vj******@excelleinc.com> wrote in message news:em****************@TK2MSFTNGP15.phx.gbl... Hello,
I'm trying to put sub that's shared between all forms in my app in module so when I make change I just change it one time.
This sub should execute and then invoke sub defaults() that's different for each form and is contained within the forms. You'll probably ask why don't I just put it in the form after the call to module.function, well it's a handler for one combobox so technically I don't call it.
I made a reference to mainform form and then did Module sharedFunction Friend Sub cbo_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) 'do something frmMainForm.ActiveMdiChild.Defaults() End Function End Module
but I'm getting error message in Visual Studio .Net "C:\Visual Studio\blabla\functions.vb(267): 'Defaults' is not a member of 'System.Windows.Forms.Form'." the program executes ok and it does call sub properly but every time I want to recompile I'm getting build error warning.
btw... sub name (Defaults) is same on each of the forms.
Thanks in advance ...
You are correct and yes, it does work :)
Had problems yesterday as I put definition for interface within the class so
it was giving me error.
Thank you very much ...
"Jim Hughes" <NO*********@Hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... You are not casting to a specifc form, you are casting each form that implements the interface to an object that implements that interface. You could even test each form to see see if it implements that interface using If frmMainForm.ActiveMdiChild Is TypeOf MyDefault Then.
All of the forms will implement that interface and therefore have a Defaults sub.
MyDefaults is the name of the Interface you define, I just used that one as an example.
If you don't believe me, do a proof of concept test of this pattern.
"excelleinc.com" <vj******@excelleinc.com> wrote in message news:ex*************@TK2MSFTNGP10.phx.gbl... This is not going to help because I can't call this from module:
CType(frmMainForm.ActiveMdiChild, MyDefaults)
Just like I said, I have different forms calling this sub and in this case MyDefaults will be bunch of different forms.
Even if I don't involve interfaces I'm able to call CType(frmMainForm.ActiveMdiChild, MyDefaults).Defaults() from the Module but as I explained, I'm not able to CType to specific form. "Jim Hughes" <NO*********@Hotmail.com> wrote in message news:uy*************@TK2MSFTNGP09.phx.gbl... Create a MyDefaults Interface with a Sub Defaults
Add the line Implements MyDefaults to each form's class
Then in your shared cbo_KeyUp sub, use CType(frmMainForm.ActiveMdiChild, MyDefaults).Defaults()
e.g.
Public Class Form1 Inherits System.Windows.Forms.Form Implements MyDefaults
Public Sub Defaults() Implements MyDefaults.Defaults 'your custom form specific code here End Sub End Class
Public Interface MyDefaults Sub Defaults() End Interface
Module sharedFunction Public frmMainForm As FormMain Friend Sub cbo_KeyUp(ByVal sender As System.Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) 'do something CType(frmMainForm.ActiveMdiChild, MyDefaults).Defaults() End Sub End Module
"excelleinc.com" <vj******@excelleinc.com> wrote in message news:em****************@TK2MSFTNGP15.phx.gbl... Hello,
I'm trying to put sub that's shared between all forms in my app in module so when I make change I just change it one time.
This sub should execute and then invoke sub defaults() that's different for each form and is contained within the forms. You'll probably ask why don't I just put it in the form after the call to module.function, well it's a handler for one combobox so technically I don't call it.
I made a reference to mainform form and then did Module sharedFunction Friend Sub cbo_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) 'do something frmMainForm.ActiveMdiChild.Defaults() End Function End Module
but I'm getting error message in Visual Studio .Net "C:\Visual Studio\blabla\functions.vb(267): 'Defaults' is not a member of 'System.Windows.Forms.Form'." the program executes ok and it does call sub properly but every time I want to recompile I'm getting build error warning.
btw... sub name (Defaults) is same on each of the forms.
Thanks in advance ...
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nick Coghlan |
last post by:
Anyone playing with the CPython interpreter's new command line switch might have
noticed that it only works with top-level modules (i.e. scripts that are
directly on sys.path). If the script is...
|
by: Jay O'Connor |
last post by:
Is there a good way to import python files without executing their content?
I'm trying some relfection based stuff and I want to be able to import a
module dynamically to check it's contents...
|
by: Nick Coghlan |
last post by:
Python 2.4's -m command line switch only works for modules directly on sys.path.
Trying to use it with modules inside packages will fail with a "Module not
found" error. This PEP aims to fix that...
|
by: ColinWard |
last post by:
whenever I run the following code I get an error saying that 'Trade Show
and Conference Contacts database could not find the form 'Events_Form'
referred to in a macro or in Visual Basic Code. The...
|
by: Stefan |
last post by:
Hello,
for the implementation of a http module I have to get to the currently
executing page handler (to query some specific page properties via
reflection). I was looking at
...
|
by: Anthony Nystrom |
last post by:
I need to exceute a method in a form from another form... Both forms will always be open so I don't have to worry about that... I just need to call the method... Please help... Source please...
|
by: Andrew Ayre |
last post by:
Hi, I have a script that I want to execute from C. I don't want to call any
functions, just execute the script. Below is a code snippet.
The problem is that PyObject_CallObject always returns...
|
by: natsran |
last post by:
Hi All,
Is there any perl module which would help in executing commands remotely on a windows machine?
For doing the same on unix machine, I found that we could use Net::Telnet module.
But...
|
by: krishna.000.k |
last post by:
file1.py
----------
a = 20
from abc import *
print "Should this be printed when 'a' is alone imported from this
module"
file2.py
----------
from file1 import a
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |